(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'undoing resolution'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (command.FuncDef name: check_resolve_undo body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:msg spids:[31]) op: Equal rhs: {($ VSub_Number '$1')} spids: [31] ) ] spids: [31] ) (C {(shift)}) (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.WhileUntil keyword: <KW_While while> cond: [ (command.Case to_match: {($ VSub_Pound '$#')} arms: [ (case_arm pat_list: [{(0)}] action: [(command.ControlFlow token:<ControlFlow_Break break>)] spids: [47 48 52 16777215] ) (case_arm pat_list: [{(1)} {(2)} {(3)}] action: [(C {(die)} {(DQ ('Bug in check-resolve-undo test'))})] spids: [55 60 68 16777215] ) ] spids: [40 44 71] ) ] body: (command.DoGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:path spids:[77]) op: Equal rhs: {($ VSub_Number '$1')} spids: [77] ) ] spids: [77] ) (C {(shift)}) (command.ForEach iter_name: stage iter_words: [{(1)} {(2)} {(3)}] do_arg_iter: F body: (command.DoGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:sha1 spids:[100]) op: Equal rhs: {($ VSub_Number '$1')} spids: [100] ) ] spids: [100] ) (C {(shift)}) (command.Case to_match: {(DQ ($ VSub_Name '$sha1'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ControlFlow token: <ControlFlow_Continue continue> ) ] spids: [116 118 122 16777215] ) ] spids: [107 113 125] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:sha1 spids:[128]) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children: [ (C {(git)} {(rev-parse)} {(--verify)} {(DQ ($ VSub_Name '$sha1'))} ) ] ) left_token: <Left_CommandSub '$('> spids: [129 139] ) } spids: [128] ) ] spids: [128] ) (C {(printf)} { (DQ ('100644 %s %s') (Lit_Other '\\') ('t%s') (Lit_Other '\\') (n)) } {($ VSub_Name '$sha1')} {($ VSub_Name '$stage')} {($ VSub_Name '$path')} ) ] spids: [97 159] ) spids: [89 16777215] ) ] spids: [74 162] ) redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_Name '$msg') (.expect))} ) ] ) (command.SimpleCommand words: [{(git)} {(ls-files)} {(--resolve-undo)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_Name '$msg') (.actual))} ) ] ) (C {(test_cmp)} {(DQ ($ VSub_Name '$msg') (.expect))} {(DQ ($ VSub_Name '$msg') (.actual))} ) ] ) ] spids: [28] ) spids: [23 27] ) (command.FuncDef name: prime_resolve_undo body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp] children: [ (C {(git)} {(reset)} {(--hard)}) (C {(git)} {(checkout)} {(second) (Lit_Other '^') (0)}) (C {(test_tick)}) (C {(test_must_fail)} {(git)} {(merge)} {(third) (Lit_Other '^') (0)}) (C {(echo)} {(merge)} {(does)} {(not)} {(leave)} {(anything)}) (C {(check_resolve_undo)} {(empty)}) (command.SimpleCommand words: [{(echo)} {(different)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(fi/le)})] ) (C {(git)} {(add)} {(fi/le)}) (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)} ) ] ) ] spids: [208] ) spids: [203 207] ) (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)}) ] )