Git merge using recursive strategy and patience option

前端 未结 2 1242
既然无缘
既然无缘 2021-02-05 03:55

How to merge a branch with git using patience option provided by the recursive strategy? I\'m using git version 1.7.3.1.msysgit.0

Even docs are not consistent and, what\

2条回答
  •  生来不讨喜
    2021-02-05 04:29

    I see here the patch introducing the patience option to the recursive merge strategy, base on Git1.7.2.2, but I don't see it in any of the subsequent release notes.

    Yet the patience diff algorithm has been presented since 2009, and is detailed here.

    > grep -i patience *.c
    diff.c: else if (!strcmp(arg, "--patience"))
    diff.c:         DIFF_XDL_SET(options, PATIENCE_DIFF);
    merge-recursive.c:      else if (!strcmp(s, "patience"))
    merge-recursive.c:              o->xdl_opts |= XDF_PATIENCE_DIFF;
    

    The merge command should understand this option... but this function below seems to never be called (not anywhere in merge-recursive.c or in any other *.c file!):

    int parse_merge_opt(struct merge_options *o, const char *s)
    {
        if (!s || !*s)
            return -1;
        if (!strcmp(s, "ours"))
            o->recursive_variant = MERGE_RECURSIVE_OURS;
        else if (!strcmp(s, "theirs"))
            o->recursive_variant = MERGE_RECURSIVE_THEIRS;
        else if (!strcmp(s, "subtree"))
            o->subtree_shift = "";
        else if (!prefixcmp(s, "subtree="))
            o->subtree_shift = s + strlen("subtree=");
        else if (!strcmp(s, "patience"))
            o->xdl_opts |= XDF_PATIENCE_DIFF;
        else if (!strcmp(s, "ignore-space-change"))
            o->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
        else if (!strcmp(s, "ignore-all-space"))
            o->xdl_opts |= XDF_IGNORE_WHITESPACE;
        else if (!strcmp(s, "ignore-space-at-eol"))
            o->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;
        else if (!strcmp(s, "renormalize"))
            o->renormalize = 1;
        else if (!strcmp(s, "no-renormalize"))
            o->renormalize = 0;
        else if (!prefixcmp(s, "rename-threshold=")) {
            const char *score = s + strlen("rename-threshold=");
            if ((o->rename_score = parse_rename_score(&score)) == -1 || *score != 0)
                return -1;
        }
        else
            return -1;
        return 0;
    }
    

    The "Unknown option" error message is only printed by the handle_options function in git.c.
    And XDF_PATIENCE_DIFF doesn't show anywhere else in git sources (1.7.4)... so yes, I don't know how this could be implemented for the merge.

提交回复
热议问题