git源码阅读

https://github.com/git-for-windows/git/issues/1854

https://github.com/git-for-windows/git/pull/1902/files

分了2步操作,第一步是git reset,第二部是git cherry-pick --continue

https://github.com/git-for-windows/git/blob/master/CONTRIBUTING.md

根据contributing.md,clone源代码。然后切换到vs/master分支。

commit

查看commit.c中的源代码中的prepare_to_commit函数,查看call hierarchy。(SHA-1: 66104e01a6ac313a8b9991d14658ca850b53598a)

merge.c中的cmd_merge函数(1274行),调用commit.c中的cmd_commit函数,  

  ret = cmd_commit(nargc, nargv, prefix);

commit.c中的cmd_commit函数(1584行),调用commit.c中的prepare_to_commit函数

if (!prepare_to_commit(index_file, prefix,
                   current_head, &s, &author_ident)) {
        rollback_index_files();
        return 1;
    }

merge.c源码中1257行

if (abort_current_merge) {
        int nargc = 2;
        const char *nargv[] = {"reset", "--merge", NULL};

        if (orig_argc != 2)
            usage_msg_opt(_("--abort expects no arguments"),
                  builtin_merge_usage, builtin_merge_options);

        if (!file_exists(git_path_merge_head(the_repository)))
            die(_("There is no merge to abort (MERGE_HEAD missing)."));

        /* Invoke 'git reset --merge' */
        ret = cmd_reset(nargc, nargv, prefix);
        goto done;
    }

cherry-pick

builtin evert.c  第224行

int cmd_cherry_pick(int argc, const char **argv, const char *prefix)

reset

builtin eset.c  第287行

int cmd_reset(int argc, const char **argv, const char *prefix)

在merge.c中有一个地方在调用。这一块代码可以参考

if (abort_current_merge) {
        int nargc = 2;
        const char *nargv[] = {"reset", "--merge", NULL};

        if (orig_argc != 2)
            usage_msg_opt(_("--abort expects no arguments"),
                  builtin_merge_usage, builtin_merge_options);

        if (!file_exists(git_path_merge_head(the_repository)))
            die(_("There is no merge to abort (MERGE_HEAD missing)."));

        /* Invoke 'git reset --merge' */
        ret = cmd_reset(nargc, nargv, prefix);
        goto done;
    }
原文地址:https://www.cnblogs.com/chucklu/p/10461116.html