]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/merge-file-exit-code'
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Oct 2015 20:07:08 +0000 (13:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Oct 2015 20:07:08 +0000 (13:07 -0700)
"git merge-file" tried to signal how many conflicts it found, which
obviously would not work well when there are too many of them.

* jk/merge-file-exit-code:
  merge-file: clamp exit code to maximum 127

Documentation/git-merge-file.txt
builtin/merge-file.c
t/t7600-merge.sh

index d2fc12ec77b85a5c9457cbfa160e5c05c1a32f43..f85603261325f6f88b31c30b5fb2bafcded58d92 100644 (file)
@@ -41,7 +41,8 @@ lines from `<other-file>`, or lines from both respectively.  The length of the
 conflict markers can be given with the `--marker-size` option.
 
 The exit value of this program is negative on error, and the number of
-conflicts otherwise. If the merge was clean, the exit value is 0.
+conflicts otherwise (truncated to 127 if there are more than that many
+conflicts). If the merge was clean, the exit value is 0.
 
 'git merge-file' is designed to be a minimal clone of RCS 'merge'; that is, it
 implements all of RCS 'merge''s functionality which is needed by
index 50d0bc873bee47ea6d1ab3b8e303e0a779465825..55447053f2dde004ceffff9967b015b4a01c35d1 100644 (file)
@@ -104,5 +104,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
                free(result.ptr);
        }
 
+       if (ret > 127)
+               ret = 127;
+
        return ret;
 }
index 75c50eea15e54995364fb8c81d0760446175f46e..302e23826341bce6c3797330b5f2996877dc5baf 100755 (executable)
@@ -692,4 +692,37 @@ test_expect_success GPG 'merge --no-edit tag should skip editor' '
        test_cmp actual expect
 '
 
+test_expect_success 'set up mod-256 conflict scenario' '
+       # 256 near-identical stanzas...
+       for i in $(test_seq 1 256); do
+               for j in 1 2 3 4 5; do
+                       echo $i-$j
+               done
+       done >file &&
+       git add file &&
+       git commit -m base &&
+
+       # one side changes the first line of each to "master"
+       sed s/-1/-master/ <file >tmp &&
+       mv tmp file &&
+       git commit -am master &&
+
+       # and the other to "side"; merging the two will
+       # yield 256 separate conflicts
+       git checkout -b side HEAD^ &&
+       sed s/-1/-side/ <file >tmp &&
+       mv tmp file &&
+       git commit -am side
+'
+
+test_expect_success 'merge detects mod-256 conflicts (recursive)' '
+       git reset --hard &&
+       test_must_fail git merge -s recursive master
+'
+
+test_expect_success 'merge detects mod-256 conflicts (resolve)' '
+       git reset --hard &&
+       test_must_fail git merge -s resolve master
+'
+
 test_done