#!/bin/sh # # Copyright (c) 2006 Johannes E. Schindelin # global test_description := ''git rerere ! [fifth] version1 ! [first] first ! [fourth] version1 ! [master] initial ! [second] prefer first over second ! [third] version2 ------ + [third] version2 + [fifth] version1 + [fourth] version1 + + + [third^] third - [second] prefer first over second + + [first] first + [second^] second ++++++ [master] initial '' source ./test-lib.sh test_expect_success 'setup' ' cat >a1 <<-\EOF && Some title ========== Whether '''''tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, '''''tis a consummation Devoutly to be wish'''''d. EOF git add a1 && test_tick && git commit -q -a -m initial && cat >>a1 <<-\EOF && Some title ========== To die, to sleep; To sleep: perchance to dream: ay, there'''''s the rub; For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause: there'''''s the respect That makes calamity of so long life; EOF git checkout -b first && test_tick && git commit -q -a -m first && git checkout -b second master && git show first:a1 | sed -e "s/To die, t/To die! T/" -e "s/Some title/Some Title/" >a1 && echo "* END *" >>a1 && test_tick && git commit -q -a -m second ' test_expect_success 'nothing recorded without rerere' ' rm -rf .git/rr-cache && git config rerere.enabled false && test_must_fail git merge first && ! test -d .git/rr-cache ' test_expect_success 'activate rerere, old style (conflicting merge)' ' git reset --hard && mkdir .git/rr-cache && test_might_fail git config --unset rerere.enabled && test_must_fail git merge first && sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && rr=.git/rr-cache/$sha1 && grep "^=======\$" $rr/preimage && ! test -f $rr/postimage && ! test -f $rr/thisimage ' test_expect_success 'rerere.enabled works, too' ' rm -rf .git/rr-cache && git config rerere.enabled true && git reset --hard && test_must_fail git merge first && sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && rr=.git/rr-cache/$sha1 && grep ^=======$ $rr/preimage ' test_expect_success 'set up rr-cache' ' rm -rf .git/rr-cache && git config rerere.enabled true && git reset --hard && test_must_fail git merge first && sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && rr=.git/rr-cache/$sha1 ' test_expect_success 'rr-cache looks sane' ' # no postimage or thisimage yet ! test -f $rr/postimage && ! test -f $rr/thisimage && # preimage has right number of lines cnt=$(sed -ne "/^<<<<<<>>>>>>/p" $rr/preimage | wc -l) && echo $cnt && test $cnt = 13 ' test_expect_success 'rerere diff' ' git show first:a1 >a1 && cat >expect <<-\EOF && --- a/a1 +++ b/a1 @@ -1,4 +1,4 @@ -Some Title +Some title ========== Whether '''''tis nobler in the mind to suffer The slings and arrows of outrageous fortune, @@ -8,21 +8,11 @@ The heart-ache and the thousand natural shocks That flesh is heir to, '''''tis a consummation Devoutly to be wish'''''d. -<<<<<<< -Some Title -========== -To die! To sleep; -======= Some title ========== To die, to sleep; ->>>>>>> To sleep: perchance to dream: ay, there'''''s the rub; For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause: there'''''s the respect That makes calamity of so long life; -<<<<<<< -======= -* END * ->>>>>>> EOF git rerere diff >out && test_cmp expect out ' test_expect_success 'rerere status' ' echo a1 >expect && git rerere status >out && test_cmp expect out ' test_expect_success 'first postimage wins' ' git show first:a1 | sed "s/To die: t/To die! T/" >expect && git commit -q -a -m "prefer first over second" && test -f $rr/postimage && oldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) && git checkout -b third master && git show second^:a1 | sed "s/To die: t/To die! T/" >a1 && git commit -q -a -m third && test_must_fail git merge first && # rerere kicked in ! grep "^=======\$" a1 && test_cmp expect a1 ' test_expect_success 'rerere updates postimage timestamp' ' newmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) && test $oldmtimepost -lt $newmtimepost ' test_expect_success 'rerere clear' ' mv $rr/postimage .git/post-saved && echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR && git rerere clear && ! test -d $rr ' test_expect_success 'leftover directory' ' git reset --hard && mkdir -p $rr && test_must_fail git merge first && test -f $rr/preimage ' test_expect_success 'missing preimage' ' git reset --hard && mkdir -p $rr && cp .git/post-saved $rr/postimage && test_must_fail git merge first && test -f $rr/preimage ' test_expect_success 'set up for garbage collection tests' ' mkdir -p $rr && echo Hello >$rr/preimage && echo World >$rr/postimage && sha2=4000000000000000000000000000000000000000 && rr2=.git/rr-cache/$sha2 && mkdir $rr2 && echo Hello >$rr2/preimage && almost_15_days_ago=$((60-15*86400)) && just_over_15_days_ago=$((-1-15*86400)) && almost_60_days_ago=$((60-60*86400)) && just_over_60_days_ago=$((-1-60*86400)) && test-chmtime =$just_over_60_days_ago $rr/preimage && test-chmtime =$almost_60_days_ago $rr/postimage && test-chmtime =$almost_15_days_ago $rr2/preimage ' test_expect_success 'gc preserves young or recently used records' ' git rerere gc && test -f $rr/preimage && test -f $rr2/preimage ' test_expect_success 'old records rest in peace' ' test-chmtime =$just_over_60_days_ago $rr/postimage && test-chmtime =$just_over_15_days_ago $rr2/preimage && git rerere gc && ! test -f $rr/preimage && ! test -f $rr2/preimage ' test_expect_success 'setup: file2 added differently in two branches' ' git reset --hard && git checkout -b fourth && echo Hallo >file2 && git add file2 && test_tick && git commit -m version1 && git checkout third && echo Bello >file2 && git add file2 && test_tick && git commit -m version2 && test_must_fail git merge fourth && echo Cello >file2 && git add file2 && git commit -m resolution ' test_expect_success 'resolution was recorded properly' ' echo Cello >expected && git reset --hard HEAD~2 && git checkout -b fifth && echo Hallo >file3 && git add file3 && test_tick && git commit -m version1 && git checkout third && echo Bello >file3 && git add file3 && test_tick && git commit -m version2 && git tag version2 && test_must_fail git merge fifth && test_cmp expected file3 && test_must_fail git update-index --refresh ' test_expect_success 'rerere.autoupdate' ' git config rerere.autoupdate true && git reset --hard && git checkout version2 && test_must_fail git merge fifth && git update-index --refresh ' test_expect_success 'merge --rerere-autoupdate' ' test_might_fail git config --unset rerere.autoupdate && git reset --hard && git checkout version2 && test_must_fail git merge --rerere-autoupdate fifth && git update-index --refresh ' test_expect_success 'merge --no-rerere-autoupdate' ' headblob=$(git rev-parse version2:file3) && mergeblob=$(git rev-parse fifth:file3) && cat >expected <<-EOF && 100644 $headblob 2 file3 100644 $mergeblob 3 file3 EOF git config rerere.autoupdate true && git reset --hard && git checkout version2 && test_must_fail git merge --no-rerere-autoupdate fifth && git ls-files -u >actual && test_cmp expected actual ' test_expect_success 'set up an unresolved merge' ' headblob=$(git rev-parse version2:file3) && mergeblob=$(git rev-parse fifth:file3) && cat >expected.unresolved <<-EOF && 100644 $headblob 2 file3 100644 $mergeblob 3 file3 EOF test_might_fail git config --unset rerere.autoupdate && git reset --hard && git checkout version2 && fifth=$(git rev-parse fifth) && echo "$fifth branch 'fifth' of ." | git fmt-merge-msg >msg && ancestor=$(git merge-base version2 fifth) && test_must_fail git merge-recursive "$ancestor" -- HEAD fifth && git ls-files --stage >failedmerge && cp file3 file3.conflict && git ls-files -u >actual && test_cmp expected.unresolved actual ' test_expect_success 'explicit rerere' ' test_might_fail git config --unset rerere.autoupdate && git rm -fr --cached . && git update-index --index-info actual && test_cmp expected.unresolved actual ' test_expect_success 'explicit rerere with autoupdate' ' git config rerere.autoupdate true && git rm -fr --cached . && git update-index --index-info actual1 && git rm -fr --cached . && git update-index --index-info actual2 && git rm -fr --cached . && git update-index --index-info err && test_i18ngrep [Uu]sage err && test_must_fail git update-index --refresh ' test_expect_success 'rerere -h' ' test_must_fail git rerere -h >help && test_i18ngrep [Uu]sage help ' proc concat_insert { global last := $1 shift cat early && printf "%s\n" @Argv && cat late $last } proc count_pre_post { find .git/rr-cache/ -type f -name "preimage*" >actual && test_line_count = $1 actual && find .git/rr-cache/ -type f -name "postimage*" >actual && test_line_count = $2 actual } test_expect_success 'rerere gc' ' find .git/rr-cache -type f >original && xargs test-chmtime -172800 actual && test_cmp original actual && git -c gc.rerereresolved=5 -c gc.rerereunresolved=0 rerere gc && find .git/rr-cache -type f >actual && test_cmp original actual && git -c gc.rerereresolved=0 -c gc.rerereunresolved=0 rerere gc && find .git/rr-cache -type f >actual && >expect && test_cmp expect actual ' proc merge_conflict_resolve { git reset --hard && test_must_fail git merge six.1 && # 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 } test_expect_success '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 merge_conflict_resolve && # 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 && git rerere remaining >actual && test_cmp expect actual && count_pre_post 2 0 && # Pretend that the conflicts were made quite some time ago find .git/rr-cache/ -type f | xargs test-chmtime -172800 && # Unresolved entries have not expired yet git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc && count_pre_post 2 0 && # Unresolved entries have expired git -c gc.rerereresolved=5 -c gc.rerereunresolved=1 rerere gc && count_pre_post 0 0 && # Recreate the conflicted state merge_conflict_resolve && count_pre_post 2 0 && # Clear it git rerere clear && count_pre_post 0 0 && # Recreate the conflicted state merge_conflict_resolve && count_pre_post 2 0 && # We resolved file1 and file2 git rerere && >expect && git rerere remaining >actual && test_cmp expect actual && # We must have recorded both of them count_pre_post 2 2 && # 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 && # Forget resolution for file2 git rerere forget file2 && echo file2 >expect && git rerere status >actual && test_cmp expect actual && count_pre_post 2 1 && # file2 already has correct resolution, so record it again git rerere && # Pretend that the resolutions are old again find .git/rr-cache/ -type f | xargs test-chmtime -172800 && # Resolved entries have not expired yet git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc && count_pre_post 2 2 && # Resolved entries have expired git -c gc.rerereresolved=1 -c gc.rerereunresolved=5 rerere gc && count_pre_post 0 0 ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git rerere\n"> <"\n"> <"! [fifth] version1\n"> <" ! [first] first\n"> <" ! [fourth] version1\n"> <" ! [master] initial\n"> <" ! [second] prefer first over second\n"> <" ! [third] version2\n"> <"------\n"> <" + [third] version2\n"> <"+ [fifth] version1\n"> <" + [fourth] version1\n"> <"+ + + [third^] third\n"> <" - [second] prefer first over second\n"> <" + + [first] first\n"> <" + [second^] second\n"> <"++++++ [master] initial\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} {(SQ <"\n"> <"\tcat >a1 <<-\\EOF &&\n"> <"\tSome title\n"> <"\t==========\n"> <"\tWhether ">) (EscapedLiteralPart token:) (SQ <"tis nobler in the mind to suffer\n"> <"\tThe slings and arrows of outrageous fortune,\n"> <"\tOr to take arms against a sea of troubles,\n"> <"\tAnd by opposing end them? To die: to sleep;\n"> <"\tNo more; and by a sleep to say we end\n"> <"\tThe heart-ache and the thousand natural shocks\n"> <"\tThat flesh is heir to, "> ) (EscapedLiteralPart token:) (SQ <"tis a consummation\n"> <"\tDevoutly to be wish">) (EscapedLiteralPart token:) (SQ <"d.\n"> <"\tEOF\n"> <"\n"> <"\tgit add a1 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -q -a -m initial &&\n"> <"\n"> <"\tcat >>a1 <<-\\EOF &&\n"> <"\tSome title\n"> <"\t==========\n"> <"\tTo die, to sleep;\n"> <"\tTo sleep: perchance to dream: ay, there"> ) (EscapedLiteralPart token:) (SQ <"s the rub;\n"> <"\tFor in that sleep of death what dreams may come\n"> <"\tWhen we have shuffled off this mortal coil,\n"> <"\tMust give us pause: there"> ) (EscapedLiteralPart token:) (SQ <"s the respect\n"> <"\tThat makes calamity of so long life;\n"> <"\tEOF\n"> <"\n"> <"\tgit checkout -b first &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -q -a -m first &&\n"> <"\n"> <"\tgit checkout -b second master &&\n"> <"\tgit show first:a1 |\n"> <"\tsed -e \"s/To die, t/To die! T/\" -e \"s/Some title/Some Title/\" >a1 &&\n"> <"\techo \"* END *\" >>a1 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -q -a -m second\n"> ) } ) (C {(test_expect_success)} {(SQ <"nothing recorded without rerere">)} { (SQ <"\n"> <"\trm -rf .git/rr-cache &&\n"> <"\tgit config rerere.enabled false &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\t! test -d .git/rr-cache\n"> ) } ) (C {(test_expect_success)} {(SQ <"activate rerere, old style (conflicting merge)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tmkdir .git/rr-cache &&\n"> <"\ttest_might_fail git config --unset rerere.enabled &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\n"> <"\tsha1=$(perl -pe \"s/\t.*//\" .git/MERGE_RR) &&\n"> <"\trr=.git/rr-cache/$sha1 &&\n"> <"\tgrep \"^=======\\$\" $rr/preimage &&\n"> <"\t! test -f $rr/postimage &&\n"> <"\t! test -f $rr/thisimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere.enabled works, too">)} { (SQ <"\n"> <"\trm -rf .git/rr-cache &&\n"> <"\tgit config rerere.enabled true &&\n"> <"\tgit reset --hard &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\n"> <"\tsha1=$(perl -pe \"s/\t.*//\" .git/MERGE_RR) &&\n"> <"\trr=.git/rr-cache/$sha1 &&\n"> <"\tgrep ^=======$ $rr/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up rr-cache">)} { (SQ <"\n"> <"\trm -rf .git/rr-cache &&\n"> <"\tgit config rerere.enabled true &&\n"> <"\tgit reset --hard &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\tsha1=$(perl -pe \"s/\t.*//\" .git/MERGE_RR) &&\n"> <"\trr=.git/rr-cache/$sha1\n"> ) } ) (C {(test_expect_success)} {(SQ <"rr-cache looks sane">)} { (SQ <"\n"> <"\t# no postimage or thisimage yet\n"> <"\t! test -f $rr/postimage &&\n"> <"\t! test -f $rr/thisimage &&\n"> <"\n"> <"\t# preimage has right number of lines\n"> <"\tcnt=$(sed -ne \"/^<<<<<<>>>>>>/p\" $rr/preimage | wc -l) &&\n"> <"\techo $cnt &&\n"> <"\ttest $cnt = 13\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere diff">)} { (SQ <"\n"> <"\tgit show first:a1 >a1 &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t--- a/a1\n"> <"\t+++ b/a1\n"> <"\t@@ -1,4 +1,4 @@\n"> <"\t-Some Title\n"> <"\t+Some title\n"> <"\t ==========\n"> <"\t Whether "> ) (EscapedLiteralPart token:) (SQ <"tis nobler in the mind to suffer\n"> <"\t The slings and arrows of outrageous fortune,\n"> <"\t@@ -8,21 +8,11 @@\n"> <"\t The heart-ache and the thousand natural shocks\n"> <"\t That flesh is heir to, "> ) (EscapedLiteralPart token:) (SQ <"tis a consummation\n"> <"\t Devoutly to be wish">) (EscapedLiteralPart token:) (SQ <"d.\n"> <"\t-<<<<<<<\n"> <"\t-Some Title\n"> <"\t-==========\n"> <"\t-To die! To sleep;\n"> <"\t-=======\n"> <"\t Some title\n"> <"\t ==========\n"> <"\t To die, to sleep;\n"> <"\t->>>>>>>\n"> <"\t To sleep: perchance to dream: ay, there"> ) (EscapedLiteralPart token:) (SQ <"s the rub;\n"> <"\t For in that sleep of death what dreams may come\n"> <"\t When we have shuffled off this mortal coil,\n"> <"\t Must give us pause: there"> ) (EscapedLiteralPart token:) (SQ <"s the respect\n"> <"\t That makes calamity of so long life;\n"> <"\t-<<<<<<<\n"> <"\t-=======\n"> <"\t-* END *\n"> <"\t->>>>>>>\n"> <"\tEOF\n"> <"\tgit rerere diff >out &&\n"> <"\ttest_cmp expect out\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere status">)} { (SQ <"\n"> <"\techo a1 >expect &&\n"> <"\tgit rerere status >out &&\n"> <"\ttest_cmp expect out\n"> ) } ) (C {(test_expect_success)} {(SQ <"first postimage wins">)} { (SQ <"\n"> <"\tgit show first:a1 | sed \"s/To die: t/To die! T/\" >expect &&\n"> <"\n"> <"\tgit commit -q -a -m \"prefer first over second\" &&\n"> <"\ttest -f $rr/postimage &&\n"> <"\n"> <"\toldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) &&\n"> <"\n"> <"\tgit checkout -b third master &&\n"> <"\tgit show second^:a1 | sed \"s/To die: t/To die! T/\" >a1 &&\n"> <"\tgit commit -q -a -m third &&\n"> <"\n"> <"\ttest_must_fail git merge first &&\n"> <"\t# rerere kicked in\n"> <"\t! grep \"^=======\\$\" a1 &&\n"> <"\ttest_cmp expect a1\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere updates postimage timestamp">)} { (SQ <"\n"> <"\tnewmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) &&\n"> <"\ttest $oldmtimepost -lt $newmtimepost\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere clear">)} { (SQ <"\n"> <"\tmv $rr/postimage .git/post-saved &&\n"> <"\techo \"$sha1\ta1\" | perl -pe \"y/\\012/\\000/\" >.git/MERGE_RR &&\n"> <"\tgit rerere clear &&\n"> <"\t! test -d $rr\n"> ) } ) (C {(test_expect_success)} {(SQ <"leftover directory">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tmkdir -p $rr &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\ttest -f $rr/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"missing preimage">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tmkdir -p $rr &&\n"> <"\tcp .git/post-saved $rr/postimage &&\n"> <"\ttest_must_fail git merge first &&\n"> <"\ttest -f $rr/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up for garbage collection tests">)} { (SQ <"\n"> <"\tmkdir -p $rr &&\n"> <"\techo Hello >$rr/preimage &&\n"> <"\techo World >$rr/postimage &&\n"> <"\n"> <"\tsha2=4000000000000000000000000000000000000000 &&\n"> <"\trr2=.git/rr-cache/$sha2 &&\n"> <"\tmkdir $rr2 &&\n"> <"\techo Hello >$rr2/preimage &&\n"> <"\n"> <"\talmost_15_days_ago=$((60-15*86400)) &&\n"> <"\tjust_over_15_days_ago=$((-1-15*86400)) &&\n"> <"\talmost_60_days_ago=$((60-60*86400)) &&\n"> <"\tjust_over_60_days_ago=$((-1-60*86400)) &&\n"> <"\n"> <"\ttest-chmtime =$just_over_60_days_ago $rr/preimage &&\n"> <"\ttest-chmtime =$almost_60_days_ago $rr/postimage &&\n"> <"\ttest-chmtime =$almost_15_days_ago $rr2/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"gc preserves young or recently used records">)} { (SQ <"\n"> <"\tgit rerere gc &&\n"> <"\ttest -f $rr/preimage &&\n"> <"\ttest -f $rr2/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"old records rest in peace">)} { (SQ <"\n"> <"\ttest-chmtime =$just_over_60_days_ago $rr/postimage &&\n"> <"\ttest-chmtime =$just_over_15_days_ago $rr2/preimage &&\n"> <"\tgit rerere gc &&\n"> <"\t! test -f $rr/preimage &&\n"> <"\t! test -f $rr2/preimage\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: file2 added differently in two branches">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\n"> <"\tgit checkout -b fourth &&\n"> <"\techo Hallo >file2 &&\n"> <"\tgit add file2 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m version1 &&\n"> <"\n"> <"\tgit checkout third &&\n"> <"\techo Bello >file2 &&\n"> <"\tgit add file2 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m version2 &&\n"> <"\n"> <"\ttest_must_fail git merge fourth &&\n"> <"\techo Cello >file2 &&\n"> <"\tgit add file2 &&\n"> <"\tgit commit -m resolution\n"> ) } ) (C {(test_expect_success)} {(SQ <"resolution was recorded properly">)} { (SQ <"\n"> <"\techo Cello >expected &&\n"> <"\n"> <"\tgit reset --hard HEAD~2 &&\n"> <"\tgit checkout -b fifth &&\n"> <"\n"> <"\techo Hallo >file3 &&\n"> <"\tgit add file3 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m version1 &&\n"> <"\n"> <"\tgit checkout third &&\n"> <"\techo Bello >file3 &&\n"> <"\tgit add file3 &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m version2 &&\n"> <"\tgit tag version2 &&\n"> <"\n"> <"\ttest_must_fail git merge fifth &&\n"> <"\ttest_cmp expected file3 &&\n"> <"\ttest_must_fail git update-index --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tgit config rerere.autoupdate true &&\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout version2 &&\n"> <"\ttest_must_fail git merge fifth &&\n"> <"\tgit update-index --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge --rerere-autoupdate">)} { (SQ <"\n"> <"\ttest_might_fail git config --unset rerere.autoupdate &&\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout version2 &&\n"> <"\ttest_must_fail git merge --rerere-autoupdate fifth &&\n"> <"\tgit update-index --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge --no-rerere-autoupdate">)} { (SQ <"\n"> <"\theadblob=$(git rev-parse version2:file3) &&\n"> <"\tmergeblob=$(git rev-parse fifth:file3) &&\n"> <"\tcat >expected <<-EOF &&\n"> <"\t100644 $headblob 2\tfile3\n"> <"\t100644 $mergeblob 3\tfile3\n"> <"\tEOF\n"> <"\n"> <"\tgit config rerere.autoupdate true &&\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout version2 &&\n"> <"\ttest_must_fail git merge --no-rerere-autoupdate fifth &&\n"> <"\tgit ls-files -u >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up an unresolved merge">)} { (SQ <"\n"> <"\theadblob=$(git rev-parse version2:file3) &&\n"> <"\tmergeblob=$(git rev-parse fifth:file3) &&\n"> <"\tcat >expected.unresolved <<-EOF &&\n"> <"\t100644 $headblob 2\tfile3\n"> <"\t100644 $mergeblob 3\tfile3\n"> <"\tEOF\n"> <"\n"> <"\ttest_might_fail git config --unset rerere.autoupdate &&\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout version2 &&\n"> <"\tfifth=$(git rev-parse fifth) &&\n"> <"\techo \"$fifth\t\tbranch "> ) (fifth) (SQ <" of .\" |\n"> <"\tgit fmt-merge-msg >msg &&\n"> <"\tancestor=$(git merge-base version2 fifth) &&\n"> <"\ttest_must_fail git merge-recursive \"$ancestor\" -- HEAD fifth &&\n"> <"\n"> <"\tgit ls-files --stage >failedmerge &&\n"> <"\tcp file3 file3.conflict &&\n"> <"\n"> <"\tgit ls-files -u >actual &&\n"> <"\ttest_cmp expected.unresolved actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"explicit rerere">)} { (SQ <"\n"> <"\ttest_might_fail git config --unset rerere.autoupdate &&\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\ttest_must_fail git update-index --refresh -q &&\n"> <"\n"> <"\tgit rerere &&\n"> <"\tgit ls-files -u >actual &&\n"> <"\ttest_cmp expected.unresolved actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"explicit rerere with autoupdate">)} { (SQ <"\n"> <"\tgit config rerere.autoupdate true &&\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\ttest_must_fail git update-index --refresh -q &&\n"> <"\n"> <"\tgit rerere &&\n"> <"\tgit update-index --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ <"explicit rerere --rerere-autoupdate overrides">)} { (SQ <"\n"> <"\tgit config rerere.autoupdate false &&\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\tgit rerere &&\n"> <"\tgit ls-files -u >actual1 &&\n"> <"\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\tgit rerere --rerere-autoupdate &&\n"> <"\tgit update-index --refresh &&\n"> <"\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\tgit rerere --rerere-autoupdate --no-rerere-autoupdate &&\n"> <"\tgit ls-files -u >actual2 &&\n"> <"\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\tgit rerere --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate &&\n"> <"\tgit update-index --refresh &&\n"> <"\n"> <"\ttest_cmp expected.unresolved actual1 &&\n"> <"\ttest_cmp expected.unresolved actual2\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere --no-no-rerere-autoupdate">)} { (SQ <"\n"> <"\tgit rm -fr --cached . &&\n"> <"\tgit update-index --index-info <"\tcp file3.conflict file3 &&\n"> <"\ttest_must_fail git rerere --no-no-rerere-autoupdate 2>err &&\n"> <"\ttest_i18ngrep [Uu]sage err &&\n"> <"\ttest_must_fail git update-index --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere -h">)} {(SQ <"\n"> <"\ttest_must_fail git rerere -h >help &&\n"> <"\ttest_i18ngrep [Uu]sage help\n">)} ) (FuncDef name: concat_insert body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:last) op: Equal rhs: {($ VSub_Number "$1")} spids: [690] ) ] spids: [690] ) (C {(shift)}) (AndOr children: [ (C {(cat)} {(early)}) (AndOr children: [ (C {(printf)} {(DQ ("%s") (EscapedLiteralPart token:))} {(DQ ($ VSub_At "$@"))} ) (C {(cat)} {(late)} {(DQ ($ VSub_Name "$last"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [687] ) spids: [682 686] ) (FuncDef name: count_pre_post body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(find)} {(.git/rr-cache/)} {(-type)} {(f)} {(-name)} {(DQ ("preimage*"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[749])] ) (AndOr children: [ (C {(test_line_count)} {(Lit_Other "=")} {(DQ ($ VSub_Number "$1"))} {(actual)}) (AndOr children: [ (SimpleCommand words: [ {(find)} {(.git/rr-cache/)} {(-type)} {(f)} {(-name)} {(DQ ("postimage*"))} ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[782])] ) (C {(test_line_count)} {(Lit_Other "=")} {(DQ ($ VSub_Number "$2"))} {(actual)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [732] ) spids: [727 731] ) (C {(test_expect_success)} {(SQ <"rerere gc">)} { (SQ <"\n"> <"\tfind .git/rr-cache -type f >original &&\n"> <"\txargs test-chmtime -172800 <"\n"> <"\tgit -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&\n"> <"\tfind .git/rr-cache -type f >actual &&\n"> <"\ttest_cmp original actual &&\n"> <"\n"> <"\tgit -c gc.rerereresolved=5 -c gc.rerereunresolved=0 rerere gc &&\n"> <"\tfind .git/rr-cache -type f >actual &&\n"> <"\ttest_cmp original actual &&\n"> <"\n"> <"\tgit -c gc.rerereresolved=0 -c gc.rerereunresolved=0 rerere gc &&\n"> <"\tfind .git/rr-cache -type f >actual &&\n"> <"\t>expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (FuncDef name: merge_conflict_resolve body: (BraceGroup children: [ (AndOr children: [ (C {(git)} {(reset)} {(--hard)}) (AndOr children: [ (C {(test_must_fail)} {(git)} {(merge)} {(six.1)}) (AndOr children: [ (SimpleCommand words: [{(concat_insert)} {(short)} {(6.1)} {(6.2)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(file1)} spids:[867])] ) (SimpleCommand words: [{(concat_insert)} {(long)} {(6.1)} {(6.2)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(file2)} spids:[881])] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [832] ) spids: [827 831] ) (C {(test_expect_success)} {(SQ <"multiple identical conflicts">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\n"> <"\ttest_seq 1 6 >early &&\n"> <"\t>late &&\n"> <"\ttest_seq 11 15 >short &&\n"> <"\ttest_seq 111 120 >long &&\n"> <"\tconcat_insert short >file1 &&\n"> <"\tconcat_insert long >file2 &&\n"> <"\tgit add file1 file2 &&\n"> <"\tgit commit -m base &&\n"> <"\tgit tag base &&\n"> <"\tgit checkout -b six.1 &&\n"> <"\tconcat_insert short 6.1 >file1 &&\n"> <"\tconcat_insert long 6.1 >file2 &&\n"> <"\tgit add file1 file2 &&\n"> <"\tgit commit -m 6.1 &&\n"> <"\tgit checkout -b six.2 HEAD^ &&\n"> <"\tconcat_insert short 6.2 >file1 &&\n"> <"\tconcat_insert long 6.2 >file2 &&\n"> <"\tgit add file1 file2 &&\n"> <"\tgit commit -m 6.2 &&\n"> <"\n"> <"\t# At this point, six.1 and six.2\n"> <"\t# - derive from common ancestor that has two files\n"> <"\t# 1...6 7 11..15 (file1) and 1...6 7 111..120 (file2)\n"> <"\t# - six.1 replaces these 7s with 6.1\n"> <"\t# - six.2 replaces these 7s with 6.2\n"> <"\n"> <"\tmerge_conflict_resolve &&\n"> <"\n"> <"\t# Check that rerere knows that file1 and file2 have conflicts\n"> <"\n"> <"\tprintf \"%s\\n\" file1 file2 >expect &&\n"> <"\tgit ls-files -u | sed -e \"s/^.*\t//\" | sort -u >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tgit rerere status | sort >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tgit rerere remaining >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tcount_pre_post 2 0 &&\n"> <"\n"> <"\t# Pretend that the conflicts were made quite some time ago\n"> <"\tfind .git/rr-cache/ -type f | xargs test-chmtime -172800 &&\n"> <"\n"> <"\t# Unresolved entries have not expired yet\n"> <"\tgit -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&\n"> <"\tcount_pre_post 2 0 &&\n"> <"\n"> <"\t# Unresolved entries have expired\n"> <"\tgit -c gc.rerereresolved=5 -c gc.rerereunresolved=1 rerere gc &&\n"> <"\tcount_pre_post 0 0 &&\n"> <"\n"> <"\t# Recreate the conflicted state\n"> <"\tmerge_conflict_resolve &&\n"> <"\tcount_pre_post 2 0 &&\n"> <"\n"> <"\t# Clear it\n"> <"\tgit rerere clear &&\n"> <"\tcount_pre_post 0 0 &&\n"> <"\n"> <"\t# Recreate the conflicted state\n"> <"\tmerge_conflict_resolve &&\n"> <"\tcount_pre_post 2 0 &&\n"> <"\n"> <"\t# We resolved file1 and file2\n"> <"\tgit rerere &&\n"> <"\t>expect &&\n"> <"\tgit rerere remaining >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\t# We must have recorded both of them\n"> <"\tcount_pre_post 2 2 &&\n"> <"\n"> <"\t# Now we should be able to resolve them both\n"> <"\tgit reset --hard &&\n"> <"\ttest_must_fail git merge six.1 &&\n"> <"\tgit rerere &&\n"> <"\n"> <"\t>expect &&\n"> <"\tgit rerere remaining >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tconcat_insert short 6.1 6.2 >file1.expect &&\n"> <"\tconcat_insert long 6.1 6.2 >file2.expect &&\n"> <"\ttest_cmp file1.expect file1 &&\n"> <"\ttest_cmp file2.expect file2 &&\n"> <"\n"> <"\t# Forget resolution for file2\n"> <"\tgit rerere forget file2 &&\n"> <"\techo file2 >expect &&\n"> <"\tgit rerere status >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tcount_pre_post 2 1 &&\n"> <"\n"> <"\t# file2 already has correct resolution, so record it again\n"> <"\tgit rerere &&\n"> <"\n"> <"\t# Pretend that the resolutions are old again\n"> <"\tfind .git/rr-cache/ -type f | xargs test-chmtime -172800 &&\n"> <"\n"> <"\t# Resolved entries have not expired yet\n"> <"\tgit -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&\n"> <"\n"> <"\tcount_pre_post 2 2 &&\n"> <"\n"> <"\t# Resolved entries have expired\n"> <"\tgit -c gc.rerereresolved=1 -c gc.rerereunresolved=5 rerere gc &&\n"> <"\tcount_pre_post 0 0\n"> ) } ) (C {(test_done)}) ] )