diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-06-24 14:58:25 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-03-15 15:32:19 -0700 |
commit | 82efa6e27e76ecd0f52a93886bcee1b8e517a662 (patch) | |
tree | 6ad93aedc8978179b5b8d4b83d56266611f223cd /t/t4200-rerere.sh | |
parent | a13d13700b05442855447670d7c3313f99f5da3c (diff) | |
download | git-82efa6e27e76ecd0f52a93886bcee1b8e517a662.tar.gz |
t4200: rerere a merge with two identical conflicts
When the context of multiple identical conflicts are different, two
seemingly the same conflict resolution cannot be safely applied.
In such a case, at least we should be able to record these two
resolutions separately in the rerere database, and reuse them when
we see the same conflict later.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4200-rerere.sh')
-rwxr-xr-x | t/t4200-rerere.sh | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index c4280110bc..6fcc6d4e75 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -406,4 +406,78 @@ test_expect_success 'rerere -h' ' test_i18ngrep [Uu]sage help ' +concat_insert () { + last=$1 + shift + cat early && printf "%s\n" "$@" && cat late "$last" +} + +test_expect_failure 'multiple identical conflicts' ' + git reset --hard && + + test_seq 1 6 >early && + >late && + test_seq 11 15 >short && + test_seq 111 120 >long && + concat_insert short >file1 && + concat_insert long >file2 && + git add file1 file2 && + git commit -m base && + git tag base && + git checkout -b six.1 && + concat_insert short 6.1 >file1 && + concat_insert long 6.1 >file2 && + git add file1 file2 && + git commit -m 6.1 && + git checkout -b six.2 HEAD^ && + concat_insert short 6.2 >file1 && + concat_insert long 6.2 >file2 && + git add file1 file2 && + git commit -m 6.2 && + + # At this point, six.1 and six.2 + # - derive from common ancestor that has two files + # 1...6 7 11..15 (file1) and 1...6 7 111..120 (file2) + # - six.1 replaces these 7s with 6.1 + # - six.2 replaces these 7s with 6.2 + + test_must_fail git merge six.1 && + + # Check that rerere knows that file1 and file2 have conflicts + + printf "%s\n" file1 file2 >expect && + git ls-files -u | sed -e "s/^.* //" | sort -u >actual && + test_cmp expect actual && + + git rerere status | sort >actual && + test_cmp expect actual && + + # Resolution is to replace 7 with 6.1 and 6.2 (i.e. take both) + concat_insert short 6.1 6.2 >file1 && + concat_insert long 6.1 6.2 >file2 && + + git rerere remaining >actual && + test_cmp expect actual && + + # We resolved file1 and file2 + git rerere && + >expect && + git rerere remaining >actual && + test_cmp expect actual && + + # Now we should be able to resolve them both + git reset --hard && + test_must_fail git merge six.1 && + git rerere && + + >expect && + git rerere remaining >actual && + test_cmp expect actual && + + concat_insert short 6.1 6.2 >file1.expect && + concat_insert long 6.1 6.2 >file2.expect && + test_cmp file1.expect file1 && + test_cmp file2.expect file2 +' + test_done |