(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"undoing resolution">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: check_resolve_undo body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:msg) op: Equal rhs: {($ VSub_Number "$1")} spids: [23] ) ] spids: [23] ) (C {(shift)}) (AndOr children: [ (While cond: [ (Case to_match: {($ VSub_Pound "$#")} arms: [ (case_arm pat_list: [{(0)}] action: [(ControlFlow token:<ControlFlow_Break break>)] spids: [39 40 44 -1] ) (case_arm pat_list: [{(1)} {(2)} {(3)}] action: [(C {(die)} {(DQ ("Bug in check-resolve-undo test"))})] spids: [47 52 60 -1] ) ] spids: [32 36 63] ) ] body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:path) op: Equal rhs: {($ VSub_Number "$1")} spids: [69] ) ] spids: [69] ) (C {(shift)}) (ForEach iter_name: stage iter_words: [{(1)} {(2)} {(3)}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sha1) op: Equal rhs: {($ VSub_Number "$1")} spids: [92] ) ] spids: [92] ) (C {(shift)}) (Case to_match: {(DQ ($ VSub_Name "$sha1"))} arms: [ (case_arm pat_list: [{(SQ )}] action: [(ControlFlow token:<ControlFlow_Continue continue>)] spids: [-1 110 114 -1] ) ] spids: [99 105 117] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(rev-parse)} {(--verify)} {(DQ ($ VSub_Name "$sha1"))} ) ] ) left_token: <Left_CommandSub "$("> spids: [121 131] ) } spids: [120] ) ] spids: [120] ) (C {(printf)} { (DQ ("100644 %s %s") (EscapedLiteralPart token: <Lit_EscapedChar "\\t"> ) ("%s") (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) ) } {($ VSub_Name "$sha1")} {($ VSub_Name "$stage")} {($ VSub_Name "$path")} ) ] spids: [89 150] ) spids: [81 -1] ) ] spids: [66 153] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$msg") (.expect))} spids: [155] ) ] ) (AndOr children: [ (SimpleCommand words: [{(git)} {(ls-files)} {(--resolve-undo)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$msg") (.actual))} spids: [170] ) ] ) (C {(test_cmp)} {(DQ ($ VSub_Name "$msg") (.expect))} {(DQ ($ VSub_Name "$msg") (.actual))} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [20] ) spids: [15 19] ) (FuncDef name: prime_resolve_undo body: (BraceGroup children: [ (AndOr children: [ (C {(git)} {(reset)} {(--hard)}) (AndOr children: [ (C {(git)} {(checkout)} {(second) (Lit_Other "^") (0)}) (AndOr children: [ (C {(test_tick)}) (AndOr children: [ (C {(test_must_fail)} {(git)} {(merge)} {(third) (Lit_Other "^") (0)}) (AndOr children: [ (C {(echo)} {(merge)} {(does)} {(not)} {(leave)} {(anything)}) (AndOr children: [ (C {(check_resolve_undo)} {(empty)}) (AndOr children: [ (SimpleCommand words: [{(echo)} {(different)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(fi/le)} spids: [266] ) ] ) (AndOr children: [ (C {(git)} {(add)} {(fi/le)}) (AndOr children: [ (C {(echo)} {(resolving)} {(records)}) (C {(check_resolve_undo)} {(recorded)} {(fi/le)} {(initial) (Lit_Other ":") (fi/le)} {(second) (Lit_Other ":") (fi/le)} {(third) (Lit_Other ":") (fi/le)} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [199] ) spids: [194 198] ) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\tmkdir fi &&\n"> <"\tprintf \"a\\0a\" >binary &&\n"> <"\tgit add binary &&\n"> <"\ttest_commit initial fi/le first &&\n"> <"\tgit branch side &&\n"> <"\tgit branch another &&\n"> <"\tprintf \"a\\0b\" >binary &&\n"> <"\tgit add binary &&\n"> <"\ttest_commit second fi/le second &&\n"> <"\tgit checkout side &&\n"> <"\ttest_commit third fi/le third &&\n"> <"\tgit branch add-add &&\n"> <"\tgit checkout another &&\n"> <"\ttest_commit fourth fi/le fourth &&\n"> <"\tgit checkout add-add &&\n"> <"\ttest_commit fifth add-differently &&\n"> <"\tgit checkout master\n"> ) } ) (C {(test_expect_success)} {(SQ <"add records switch clears">)} { (SQ <"\n"> <"\tprime_resolve_undo &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m merged &&\n"> <"\techo committing keeps &&\n"> <"\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n"> <"\tgit checkout second^0 &&\n"> <"\techo switching clears &&\n"> <"\tcheck_resolve_undo cleared\n"> ) } ) (C {(test_expect_success)} {(SQ <"rm records reset clears">)} { (SQ <"\n"> <"\tprime_resolve_undo &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m merged &&\n"> <"\techo committing keeps &&\n"> <"\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n"> <"\n"> <"\techo merge clears upfront &&\n"> <"\ttest_must_fail git merge fourth^0 &&\n"> <"\tcheck_resolve_undo nuked &&\n"> <"\n"> <"\tgit rm -f fi/le &&\n"> <"\techo resolving records &&\n"> <"\tcheck_resolve_undo recorded fi/le initial:fi/le HEAD:fi/le fourth:fi/le &&\n"> <"\n"> <"\tgit reset --hard &&\n"> <"\techo resetting discards &&\n"> <"\tcheck_resolve_undo discarded\n"> ) } ) (C {(test_expect_success)} {(SQ <"plumbing clears">)} { (SQ <"\n"> <"\tprime_resolve_undo &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m merged &&\n"> <"\techo committing keeps &&\n"> <"\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n"> <"\n"> <"\techo plumbing clear &&\n"> <"\tgit update-index --clear-resolve-undo &&\n"> <"\tcheck_resolve_undo cleared\n"> ) } ) (C {(test_expect_success)} {(SQ <"add records checkout -m undoes">)} { (SQ <"\n"> <"\tprime_resolve_undo &&\n"> <"\tgit diff HEAD &&\n"> <"\tgit checkout --conflict=merge fi/le &&\n"> <"\techo checkout used the record and removed it &&\n"> <"\tcheck_resolve_undo removed &&\n"> <"\techo the index and the work tree is unmerged again &&\n"> <"\tgit diff >actual &&\n"> <"\tgrep \"^++<<<<<<<\" actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"unmerge with plumbing">)} { (SQ <"\n"> <"\tprime_resolve_undo &&\n"> <"\tgit update-index --unresolve fi/le &&\n"> <"\tgit ls-files -u >actual &&\n"> <"\ttest_line_count = 3 actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere and rerere forget">)} { (SQ <"\n"> <"\tmkdir .git/rr-cache &&\n"> <"\tprime_resolve_undo &&\n"> <"\techo record the resolution &&\n"> <"\tgit rerere &&\n"> <"\trerere_id=$(cd .git/rr-cache && echo */postimage) &&\n"> <"\trerere_id=${rerere_id%/postimage} &&\n"> <"\ttest -f .git/rr-cache/$rerere_id/postimage &&\n"> <"\tgit checkout -m fi/le &&\n"> <"\techo resurrect the conflict &&\n"> <"\tgrep \"^=======\" fi/le &&\n"> <"\techo reresolve the conflict &&\n"> <"\tgit rerere &&\n"> <"\ttest \"z$(cat fi/le)\" = zdifferent &&\n"> <"\techo register the resolution again &&\n"> <"\tgit add fi/le &&\n"> <"\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n"> <"\ttest -z \"$(git ls-files -u)\" &&\n"> <"\tgit rerere forget fi/le &&\n"> <"\t! test -f .git/rr-cache/$rerere_id/postimage &&\n"> <"\ttr \"\\0\" \"\\n\" <.git/MERGE_RR >actual &&\n"> <"\techo \"$rerere_id\tfi/le\" >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere and rerere forget (subdirectory)">)} { (SQ <"\n"> <"\trm -fr .git/rr-cache &&\n"> <"\tmkdir .git/rr-cache &&\n"> <"\tprime_resolve_undo &&\n"> <"\techo record the resolution &&\n"> <"\t(cd fi && git rerere) &&\n"> <"\trerere_id=$(cd .git/rr-cache && echo */postimage) &&\n"> <"\trerere_id=${rerere_id%/postimage} &&\n"> <"\ttest -f .git/rr-cache/$rerere_id/postimage &&\n"> <"\t(cd fi && git checkout -m le) &&\n"> <"\techo resurrect the conflict &&\n"> <"\tgrep \"^=======\" fi/le &&\n"> <"\techo reresolve the conflict &&\n"> <"\t(cd fi && git rerere) &&\n"> <"\ttest \"z$(cat fi/le)\" = zdifferent &&\n"> <"\techo register the resolution again &&\n"> <"\t(cd fi && git add le) &&\n"> <"\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n"> <"\ttest -z \"$(git ls-files -u)\" &&\n"> <"\t(cd fi && git rerere forget le) &&\n"> <"\t! test -f .git/rr-cache/$rerere_id/postimage &&\n"> <"\ttr \"\\0\" \"\\n\" <.git/MERGE_RR >actual &&\n"> <"\techo \"$rerere_id\tfi/le\" >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere forget (binary)">)} { (SQ <"\n"> <"\tgit checkout -f side &&\n"> <"\tprintf \"a\\0c\" >binary &&\n"> <"\tgit commit -a -m binary &&\n"> <"\ttest_must_fail git merge second &&\n"> <"\tgit rerere forget binary\n"> ) } ) (C {(test_expect_success)} {(SQ <"rerere forget (add-add conflict)">)} { (SQ <"\n"> <"\tgit checkout -f master &&\n"> <"\techo master >add-differently &&\n"> <"\tgit add add-differently &&\n"> <"\tgit commit -m \"add differently\" &&\n"> <"\ttest_must_fail git merge fifth &&\n"> <"\tgit rerere forget add-differently 2>actual &&\n"> <"\ttest_i18ngrep \"no remembered\" actual\n"> ) } ) (C {(test_done)}) ] )