(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: { (SQ (Token id:Id.Lit_Chars val:'test aborting in-progress merges\n' span_id:6) (Token id:Id.Lit_Chars val:'\n' span_id:7) (Token id:Id.Lit_Chars val:'Set up repo with conflicting and non-conflicting branches:\n' span_id:8) (Token id:Id.Lit_Chars val:'\n' span_id:9) (Token id: Id.Lit_Chars val: 'There are three files foo/bar/baz, and the following graph illustrates the\n' span_id: 10 ) (Token id:Id.Lit_Chars val:'content of these files in each commit:\n' span_id:11) (Token id:Id.Lit_Chars val:'\n' span_id:12) (Token id:Id.Lit_Chars val:'# foo/bar/baz --- foo/bar/bazz <-- master\n' span_id:13) (Token id:Id.Lit_Chars val:'# \\\n' span_id:14) (Token id:Id.Lit_Chars val:'# --- foo/barf/bazf <-- conflict_branch\n' span_id:15) (Token id:Id.Lit_Chars val:'# \\\n' span_id:16) (Token id:Id.Lit_Chars val:'# --- foo/bart/baz <-- clean_branch\n' span_id:17) (Token id:Id.Lit_Chars val:'\n' span_id:18) (Token id:Id.Lit_Chars val:'Next, test git merge --abort with the following variables:\n' span_id:19) (Token id: Id.Lit_Chars val: '- before/after successful merge (should fail when not in merge context)\n' span_id: 20 ) (Token id:Id.Lit_Chars val:'- with/without conflicts\n' span_id:21) (Token id: Id.Lit_Chars val: '- clean/dirty index before merge\n' span_id: 22 ) (Token id:Id.Lit_Chars val:'- clean/dirty worktree before merge\n' span_id:23) (Token id: Id.Lit_Chars val: '- dirty index before merge matches contents on remote branch\n' span_id: 24 ) (Token id:Id.Lit_Chars val:'- changed/unchanged worktree after merge\n' span_id:25) (Token id: Id.Lit_Chars val: '- changed/unchanged index after merge\n' span_id: 26 ) ) } spids: [4] ) ] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:setup span_id:37))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:41) (Token id:Id.Lit_Chars val:'\t# Create the above repo\n' span_id:42) (Token id:Id.Lit_Chars val:'\techo foo > foo &&\n' span_id:43) (Token id:Id.Lit_Chars val:'\techo bar > bar &&\n' span_id:44) (Token id:Id.Lit_Chars val:'\techo baz > baz &&\n' span_id:45) (Token id:Id.Lit_Chars val:'\tgit add foo bar baz &&\n' span_id:46) (Token id:Id.Lit_Chars val:'\tgit commit -m initial &&\n' span_id:47) (Token id:Id.Lit_Chars val:'\techo bazz > baz &&\n' span_id:48) (Token id:Id.Lit_Chars val:'\tgit commit -a -m "second" &&\n' span_id:49) (Token id: Id.Lit_Chars val: '\tgit checkout -b conflict_branch HEAD^ &&\n' span_id: 50 ) (Token id:Id.Lit_Chars val:'\techo barf > bar &&\n' span_id:51) (Token id:Id.Lit_Chars val:'\techo bazf > baz &&\n' span_id:52) (Token id:Id.Lit_Chars val:'\tgit commit -a -m "conflict" &&\n' span_id:53) (Token id: Id.Lit_Chars val: '\tgit checkout -b clean_branch HEAD^ &&\n' span_id: 54 ) (Token id:Id.Lit_Chars val:'\techo bart > bar &&\n' span_id:55) (Token id:Id.Lit_Chars val:'\tgit commit -a -m "clean" &&\n' span_id:56) (Token id:Id.Lit_Chars val:'\tgit checkout master\n' span_id:57) ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pre_merge_head) op: assign_op.Equal rhs: { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:63) command_list: (command.CommandList children:[(C {(git)} {(rev-parse)} {(HEAD)})]) ) ) } spids: [61] ) ] ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'fails without MERGE_HEAD (unstarted merge)' span_id:76))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:80) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --abort 2>output &&\n' span_id: 81 ) (Token id:Id.Lit_Chars val:'\ttest_i18ngrep MERGE_HEAD output\n' span_id:82) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' span_id: 89 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:93) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:94) (Token id:Id.Lit_Chars val:'\ttest "$pre_merge_head" = "$(git rev-parse HEAD)"\n' span_id:95) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'fails without MERGE_HEAD (completed merge)' span_id:102))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:106) (Token id:Id.Lit_Chars val:'\tgit merge clean_branch &&\n' span_id:107) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:108) (Token id:Id.Lit_Chars val:'\t# Merge successfully completed\n' span_id:109) (Token id:Id.Lit_Chars val:'\tpost_merge_head="$(git rev-parse HEAD)" &&\n' span_id:110) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --abort 2>output &&\n' span_id: 111 ) (Token id:Id.Lit_Chars val:'\ttest_i18ngrep MERGE_HEAD output\n' span_id:112) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' span_id: 119 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:123) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:124) (Token id:Id.Lit_Chars val:'\ttest "$post_merge_head" = "$(git rev-parse HEAD)"\n' span_id:125) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Forget previous merge' span_id:132))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:136) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:137) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Abort after --no-commit' span_id:144))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:148) (Token id: Id.Lit_Chars val: '\t# Redo merge, but stop before creating merge commit\n' span_id: 149 ) (Token id:Id.Lit_Chars val:'\tgit merge --no-commit clean_branch &&\n' span_id:150) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:151) (Token id:Id.Lit_Chars val:'\t# Abort non-conflicting merge\n' span_id:152) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:153) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:154) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 155 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)" &&\n' span_id:156) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)"\n' span_id:157) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Abort after conflicts' span_id:164))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:168) (Token id:Id.Lit_Chars val:'\t# Create conflicting merge\n' span_id:169) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge conflict_branch &&\n' span_id:170) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:171) (Token id:Id.Lit_Chars val:'\t# Abort conflicting merge\n' span_id:172) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:173) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:174) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 175 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)" &&\n' span_id:176) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)"\n' span_id:177) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Clean merge with dirty index fails' span_id:184))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:188) (Token id:Id.Lit_Chars val:'\techo xyzzy >> foo &&\n' span_id:189) (Token id:Id.Lit_Chars val:'\tgit add foo &&\n' span_id:190) (Token id:Id.Lit_Chars val:'\tgit diff --staged > expect &&\n' span_id:191) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge clean_branch &&\n' span_id:192) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:193) (Token id:Id.Lit_Chars val:'\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id:194) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)" &&\n' span_id:195) (Token id:Id.Lit_Chars val:'\tgit diff --staged > actual &&\n' span_id:196) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:197) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Conflicting merge with dirty index fails' span_id:204))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:208) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge conflict_branch &&\n' span_id: 209 ) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:210) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 211 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)" &&\n' span_id:212) (Token id:Id.Lit_Chars val:'\tgit diff --staged > actual &&\n' span_id:213) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:214) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset index (but preserve worktree changes)' span_id:221))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:225) (Token id:Id.Lit_Chars val:'\tgit reset "$pre_merge_head" &&\n' span_id:226) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:227) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:228) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Abort clean merge with non-conflicting dirty worktree' span_id: 235 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:239) (Token id: Id.Lit_Chars val: '\tgit merge --no-commit clean_branch &&\n' span_id: 240 ) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:241) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:242) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:243) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:244) (Token id:Id.Lit_Chars val:'\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id:245) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:246) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:247) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:248) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Abort conflicting merge with non-conflicting dirty worktree' span_id: 255 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:259) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge conflict_branch &&\n' span_id: 260 ) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:261) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:262) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:263) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:264) (Token id:Id.Lit_Chars val:'\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id:265) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:266) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:267) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:268) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset worktree changes' span_id:275))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:279) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:280) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Fail clean merge with conflicting dirty worktree' span_id: 287 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:291) (Token id:Id.Lit_Chars val:'\techo xyzzy >> bar &&\n' span_id:292) (Token id:Id.Lit_Chars val:'\tgit diff > expect &&\n' span_id:293) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --no-commit clean_branch &&\n' span_id: 294 ) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:295) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 296 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:297) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:298) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:299) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Fail conflicting merge with conflicting dirty worktree' span_id: 306 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:310) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge conflict_branch &&\n' span_id: 311 ) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:312) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 313 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:314) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:315) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:316) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset worktree changes' span_id:323))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:327) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:328) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Fail clean merge with matching dirty worktree' span_id:335))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:339) (Token id:Id.Lit_Chars val:'\techo bart > bar &&\n' span_id:340) (Token id:Id.Lit_Chars val:'\tgit diff > expect &&\n' span_id:341) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge --no-commit clean_branch &&\n' span_id: 342 ) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:343) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 344 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:345) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:346) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:347) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Abort clean merge with matching dirty index' span_id:354))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:358) (Token id:Id.Lit_Chars val:'\tgit add bar &&\n' span_id:359) (Token id:Id.Lit_Chars val:'\tgit diff --staged > expect &&\n' span_id:360) (Token id: Id.Lit_Chars val: '\tgit merge --no-commit clean_branch &&\n' span_id: 361 ) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:362) (Token id: Id.Lit_Chars val: '\t### When aborting the merge, git will discard all staged changes,\n' span_id: 363 ) (Token id: Id.Lit_Chars val: '\t### including those that were staged pre-merge. In other words,\n' span_id: 364 ) (Token id: Id.Lit_Chars val: '\t### --abort will LOSE any staged changes (the staged changes that\n' span_id: 365 ) (Token id: Id.Lit_Chars val: '\t### are lost must match the merge result, or the merge would not\n' span_id: 366 ) (Token id: Id.Lit_Chars val: '\t### have been allowed to start). Change expectations accordingly:\n' span_id: 367 ) (Token id:Id.Lit_Chars val:'\trm expect &&\n' span_id:368) (Token id:Id.Lit_Chars val:'\ttouch expect &&\n' span_id:369) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:370) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:371) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:372) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 373 ) (Token id:Id.Lit_Chars val:'\tgit diff --staged > actual &&\n' span_id:374) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:375) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)"\n' span_id:376) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset worktree changes' span_id:383))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:387) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:388) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Fail conflicting merge with matching dirty worktree' span_id: 395 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:399) (Token id:Id.Lit_Chars val:'\techo barf > bar &&\n' span_id:400) (Token id:Id.Lit_Chars val:'\tgit diff > expect &&\n' span_id:401) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge conflict_branch &&\n' span_id: 402 ) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:403) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 404 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff --staged)" &&\n' span_id:405) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:406) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:407) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Abort conflicting merge with matching dirty index' span_id: 414 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:418) (Token id:Id.Lit_Chars val:'\tgit add bar &&\n' span_id:419) (Token id:Id.Lit_Chars val:'\tgit diff --staged > expect &&\n' span_id:420) (Token id: Id.Lit_Chars val: '\ttest_must_fail git merge conflict_branch &&\n' span_id: 421 ) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:422) (Token id: Id.Lit_Chars val: '\t### When aborting the merge, git will discard all staged changes,\n' span_id: 423 ) (Token id: Id.Lit_Chars val: '\t### including those that were staged pre-merge. In other words,\n' span_id: 424 ) (Token id: Id.Lit_Chars val: '\t### --abort will LOSE any staged changes (the staged changes that\n' span_id: 425 ) (Token id: Id.Lit_Chars val: '\t### are lost must match the merge result, or the merge would not\n' span_id: 426 ) (Token id: Id.Lit_Chars val: '\t### have been allowed to start). Change expectations accordingly:\n' span_id: 427 ) (Token id:Id.Lit_Chars val:'\trm expect &&\n' span_id:428) (Token id:Id.Lit_Chars val:'\ttouch expect &&\n' span_id:429) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:430) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:431) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:432) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 433 ) (Token id:Id.Lit_Chars val:'\tgit diff --staged > actual &&\n' span_id:434) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:435) (Token id:Id.Lit_Chars val:'\ttest -z "$(git diff)"\n' span_id:436) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset worktree changes' span_id:443))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:447) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:448) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Abort merge with pre- and post-merge worktree changes' span_id: 455 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:459) (Token id:Id.Lit_Chars val:'\t# Pre-merge worktree changes\n' span_id:460) (Token id:Id.Lit_Chars val:'\techo xyzzy > foo &&\n' span_id:461) (Token id:Id.Lit_Chars val:'\techo barf > bar &&\n' span_id:462) (Token id:Id.Lit_Chars val:'\tgit add bar &&\n' span_id:463) (Token id:Id.Lit_Chars val:'\tgit diff > expect &&\n' span_id:464) (Token id:Id.Lit_Chars val:'\tgit diff --staged > expect-staged &&\n' span_id:465) (Token id:Id.Lit_Chars val:'\t# Perform merge\n' span_id:466) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge conflict_branch &&\n' span_id:467) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:468) (Token id:Id.Lit_Chars val:'\t# Post-merge worktree changes\n' span_id:469) (Token id:Id.Lit_Chars val:'\techo yzxxz > foo &&\n' span_id:470) (Token id:Id.Lit_Chars val:'\techo blech > baz &&\n' span_id:471) (Token id: Id.Lit_Chars val: '\t### When aborting the merge, git will discard staged changes (bar)\n' span_id: 472 ) (Token id: Id.Lit_Chars val: '\t### and unmerged changes (baz). Other changes that are neither\n' span_id: 473 ) (Token id: Id.Lit_Chars val: '\t### staged nor marked as unmerged (foo), will be preserved. For\n' span_id: 474 ) (Token id: Id.Lit_Chars val: '\t### these changed, git cannot tell pre-merge changes apart from\n' span_id: 475 ) (Token id: Id.Lit_Chars val: '\t### post-merge changes, so the post-merge changes will be\n' span_id: 476 ) (Token id:Id.Lit_Chars val:'\t### preserved. Change expectations accordingly:\n' span_id:477) (Token id:Id.Lit_Chars val:'\tgit diff -- foo > expect &&\n' span_id:478) (Token id:Id.Lit_Chars val:'\trm expect-staged &&\n' span_id:479) (Token id:Id.Lit_Chars val:'\ttouch expect-staged &&\n' span_id:480) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:481) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:482) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:483) (Token id: Id.Lit_Chars val: '\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id: 484 ) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:485) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:486) (Token id:Id.Lit_Chars val:'\tgit diff --staged > actual-staged &&\n' span_id:487) (Token id: Id.Lit_Chars val: '\ttest_cmp expect-staged actual-staged\n' span_id: 488 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'Reset worktree changes' span_id:495))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:499) (Token id:Id.Lit_Chars val:'\tgit reset --hard "$pre_merge_head"\n' span_id:500) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'Abort merge with pre- and post-merge index changes' span_id: 507 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:511) (Token id:Id.Lit_Chars val:'\t# Pre-merge worktree changes\n' span_id:512) (Token id:Id.Lit_Chars val:'\techo xyzzy > foo &&\n' span_id:513) (Token id:Id.Lit_Chars val:'\techo barf > bar &&\n' span_id:514) (Token id:Id.Lit_Chars val:'\tgit add bar &&\n' span_id:515) (Token id:Id.Lit_Chars val:'\tgit diff > expect &&\n' span_id:516) (Token id:Id.Lit_Chars val:'\tgit diff --staged > expect-staged &&\n' span_id:517) (Token id:Id.Lit_Chars val:'\t# Perform merge\n' span_id:518) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge conflict_branch &&\n' span_id:519) (Token id:Id.Lit_Chars val:'\ttest -f .git/MERGE_HEAD &&\n' span_id:520) (Token id:Id.Lit_Chars val:'\t# Post-merge worktree changes\n' span_id:521) (Token id:Id.Lit_Chars val:'\techo yzxxz > foo &&\n' span_id:522) (Token id:Id.Lit_Chars val:'\techo blech > baz &&\n' span_id:523) (Token id:Id.Lit_Chars val:'\tgit add foo bar &&\n' span_id:524) (Token id: Id.Lit_Chars val: '\t### When aborting the merge, git will discard all staged changes\n' span_id: 525 ) (Token id: Id.Lit_Chars val: '\t### (foo, bar and baz), and no changes will be preserved. Whether\n' span_id: 526 ) (Token id: Id.Lit_Chars val: '\t### the changes were staged pre- or post-merge does not matter\n' span_id: 527 ) (Token id:Id.Lit_Chars val:'\t### (except for not preventing starting the merge).\n' span_id:528) (Token id: Id.Lit_Chars val: '\t### Change expectations accordingly:\n' span_id: 529 ) (Token id:Id.Lit_Chars val:'\trm expect expect-staged &&\n' span_id:530) (Token id:Id.Lit_Chars val:'\ttouch expect &&\n' span_id:531) (Token id:Id.Lit_Chars val:'\ttouch expect-staged &&\n' span_id:532) (Token id:Id.Lit_Chars val:'\t# Abort merge\n' span_id:533) (Token id:Id.Lit_Chars val:'\tgit merge --abort &&\n' span_id:534) (Token id:Id.Lit_Chars val:'\ttest ! -f .git/MERGE_HEAD &&\n' span_id:535) (Token id:Id.Lit_Chars val:'\ttest "$pre_merge_head" = "$(git rev-parse HEAD)" &&\n' span_id:536) (Token id:Id.Lit_Chars val:'\tgit diff > actual &&\n' span_id:537) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:538) (Token id: Id.Lit_Chars val: '\tgit diff --staged > actual-staged &&\n' span_id: 539 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect-staged actual-staged\n' span_id:540) ) } ) (C {(test_done)}) ] )