(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: 'Tests for "git reset" with "--merge" and "--keep" options' span_id: 15 ) ) } spids: [13] ) ] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:29) (Token id: Id.Lit_Chars val: ' for i in 1 2 3; do echo line $i; done >file1 &&\n' span_id: 30 ) (Token id:Id.Lit_Chars val:' cat file1 >file2 &&\n' span_id:31) (Token id:Id.Lit_Chars val:' git add file1 file2 &&\n' span_id:32) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:33) (Token id:Id.Lit_Chars val:' git commit -m "Initial commit" &&\n' span_id:34) (Token id:Id.Lit_Chars val:' git tag initial &&\n' span_id:35) (Token id:Id.Lit_Chars val:' echo line 4 >>file1 &&\n' span_id:36) (Token id:Id.Lit_Chars val:' cat file1 >file2 &&\n' span_id:37) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:38) (Token id:Id.Lit_Chars val:' git commit -m "add line 4 to file1" file1 &&\n' span_id:39) (Token id:Id.Lit_Chars val:' git tag second\n' span_id:40) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge is ok with changes in file it does not touch' span_id: 65 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:69) (Token id:Id.Lit_Chars val:' git reset --merge HEAD^ &&\n' span_id:70) (Token id:Id.Lit_Chars val:' ! grep 4 file1 &&\n' span_id:71) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:72) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&\n' span_id: 73 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:74) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'reset --merge is ok when switching back' span_id:81))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:85) (Token id:Id.Lit_Chars val:' git reset --merge second &&\n' span_id:86) (Token id:Id.Lit_Chars val:' grep 4 file1 &&\n' span_id:87) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:88) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 89 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:90) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --keep is ok with changes in file it does not touch' span_id: 115 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:119) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:120) (Token id:Id.Lit_Chars val:' cat file1 >file2 &&\n' span_id:121) (Token id:Id.Lit_Chars val:' git reset --keep HEAD^ &&\n' span_id:122) (Token id:Id.Lit_Chars val:' ! grep 4 file1 &&\n' span_id:123) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:124) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&\n' span_id: 125 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:126) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'reset --keep is ok when switching back' span_id:133))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:137) (Token id:Id.Lit_Chars val:' git reset --keep second &&\n' span_id:138) (Token id:Id.Lit_Chars val:' grep 4 file1 &&\n' span_id:139) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:140) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 141 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:142) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge discards changes added to index (1)' span_id: 167 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:171) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:172) (Token id:Id.Lit_Chars val:' cat file1 >file2 &&\n' span_id:173) (Token id:Id.Lit_Chars val:' echo "line 5" >> file1 &&\n' span_id:174) (Token id:Id.Lit_Chars val:' git add file1 &&\n' span_id:175) (Token id:Id.Lit_Chars val:' git reset --merge HEAD^ &&\n' span_id:176) (Token id:Id.Lit_Chars val:' ! grep 4 file1 &&\n' span_id:177) (Token id:Id.Lit_Chars val:' ! grep 5 file1 &&\n' span_id:178) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:179) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&\n' span_id: 180 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:181) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge is ok again when switching back (1)' span_id: 188 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:192) (Token id:Id.Lit_Chars val:' git reset --hard initial &&\n' span_id:193) (Token id:Id.Lit_Chars val:' echo "line 5" >> file2 &&\n' span_id:194) (Token id:Id.Lit_Chars val:' git add file2 &&\n' span_id:195) (Token id:Id.Lit_Chars val:' git reset --merge second &&\n' span_id:196) (Token id:Id.Lit_Chars val:' ! grep 4 file2 &&\n' span_id:197) (Token id:Id.Lit_Chars val:' ! grep 5 file1 &&\n' span_id:198) (Token id:Id.Lit_Chars val:' grep 4 file1 &&\n' span_id:199) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 200 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:201) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --keep fails with changes in index in files it touches' span_id: 223 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:227) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:228) (Token id:Id.Lit_Chars val:' echo "line 5" >> file1 &&\n' span_id:229) (Token id:Id.Lit_Chars val:' git add file1 &&\n' span_id:230) (Token id:Id.Lit_Chars val:' test_must_fail git reset --keep HEAD^\n' span_id:231) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge discards changes added to index (2)' span_id: 256 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:260) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:261) (Token id:Id.Lit_Chars val:' echo "line 4" >> file2 &&\n' span_id:262) (Token id:Id.Lit_Chars val:' git add file2 &&\n' span_id:263) (Token id:Id.Lit_Chars val:' git reset --merge HEAD^ &&\n' span_id:264) (Token id:Id.Lit_Chars val:' ! grep 4 file2 &&\n' span_id:265) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&\n' span_id: 266 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff)" &&\n' span_id:267) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:268) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge is ok again when switching back (2)' span_id: 275 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:279) (Token id:Id.Lit_Chars val:' git reset --hard initial &&\n' span_id:280) (Token id:Id.Lit_Chars val:' git reset --merge second &&\n' span_id:281) (Token id:Id.Lit_Chars val:' ! grep 4 file2 &&\n' span_id:282) (Token id:Id.Lit_Chars val:' grep 4 file1 &&\n' span_id:283) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 284 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:285) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'reset --keep keeps changes it does not touch' span_id:310))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:314) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:315) (Token id:Id.Lit_Chars val:' echo "line 4" >> file2 &&\n' span_id:316) (Token id:Id.Lit_Chars val:' git add file2 &&\n' span_id:317) (Token id:Id.Lit_Chars val:' git reset --keep HEAD^ &&\n' span_id:318) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:319) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&\n' span_id: 320 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:321) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'reset --keep keeps changes when switching back' span_id:328))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:332) (Token id:Id.Lit_Chars val:' git reset --keep second &&\n' span_id:333) (Token id:Id.Lit_Chars val:' grep 4 file2 &&\n' span_id:334) (Token id:Id.Lit_Chars val:' grep 4 file1 &&\n' span_id:335) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 336 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)"\n' span_id:337) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --merge fails with changes in file it touches' span_id: 359 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:363) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:364) (Token id:Id.Lit_Chars val:' echo "line 5" >> file1 &&\n' span_id:365) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:366) (Token id:Id.Lit_Chars val:' git commit -m "add line 5" file1 &&\n' span_id:367) (Token id: Id.Lit_Chars val: ' sed -e "s/line 1/changed line 1/" <file1 >file3 &&\n' span_id: 368 ) (Token id:Id.Lit_Chars val:' mv file3 file1 &&\n' span_id:369) (Token id: Id.Lit_Chars val: ' test_must_fail git reset --merge HEAD^ 2>err.log &&\n' span_id: 370 ) (Token id:Id.Lit_Chars val:' grep file1 err.log | grep "not uptodate"\n' span_id:371) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'reset --keep fails with changes in file it touches' span_id: 393 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:397) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:398) (Token id:Id.Lit_Chars val:' echo "line 5" >> file1 &&\n' span_id:399) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:400) (Token id:Id.Lit_Chars val:' git commit -m "add line 5" file1 &&\n' span_id:401) (Token id: Id.Lit_Chars val: ' sed -e "s/line 1/changed line 1/" <file1 >file3 &&\n' span_id: 402 ) (Token id:Id.Lit_Chars val:' mv file3 file1 &&\n' span_id:403) (Token id: Id.Lit_Chars val: ' test_must_fail git reset --keep HEAD^ 2>err.log &&\n' span_id: 404 ) (Token id:Id.Lit_Chars val:' grep file1 err.log | grep "not uptodate"\n' span_id:405) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup 3 different branches' span_id:412))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:416) (Token id:Id.Lit_Chars val:' git reset --hard second &&\n' span_id:417) (Token id:Id.Lit_Chars val:' git branch branch1 &&\n' span_id:418) (Token id:Id.Lit_Chars val:' git branch branch2 &&\n' span_id:419) (Token id:Id.Lit_Chars val:' git branch branch3 &&\n' span_id:420) (Token id:Id.Lit_Chars val:' git checkout branch1 &&\n' span_id:421) (Token id:Id.Lit_Chars val:' echo "line 5 in branch1" >> file1 &&\n' span_id:422) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:423) (Token id:Id.Lit_Chars val:' git commit -a -m "change in branch1" &&\n' span_id:424) (Token id:Id.Lit_Chars val:' git checkout branch2 &&\n' span_id:425) (Token id:Id.Lit_Chars val:' echo "line 5 in branch2" >> file1 &&\n' span_id:426) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:427) (Token id:Id.Lit_Chars val:' git commit -a -m "change in branch2" &&\n' span_id:428) (Token id:Id.Lit_Chars val:' git tag third &&\n' span_id:429) (Token id:Id.Lit_Chars val:' git checkout branch3 &&\n' span_id:430) (Token id:Id.Lit_Chars val:' echo a new file >file3 &&\n' span_id:431) (Token id:Id.Lit_Chars val:' rm -f file1 &&\n' span_id:432) (Token id:Id.Lit_Chars val:' git add file3 &&\n' span_id:433) (Token id:Id.Lit_Chars val:' test_tick &&\n' span_id:434) (Token id: Id.Lit_Chars val: ' git commit -a -m "change in branch3"\n' span_id: 435 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'"reset --merge HEAD^" is ok with pending merge' span_id:457))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:461) (Token id:Id.Lit_Chars val:' git checkout third &&\n' span_id:462) (Token id:Id.Lit_Chars val:' test_must_fail git merge branch1 &&\n' span_id:463) (Token id:Id.Lit_Chars val:' git reset --merge HEAD^ &&\n' span_id:464) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse second)" &&\n' span_id: 465 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)" &&\n' span_id:466) (Token id:Id.Lit_Chars val:' test -z "$(git diff)"\n' span_id:467) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'"reset --keep HEAD^" fails with pending merge' span_id:489))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:493) (Token id:Id.Lit_Chars val:' git reset --hard third &&\n' span_id:494) (Token id:Id.Lit_Chars val:' test_must_fail git merge branch1 &&\n' span_id:495) (Token id: Id.Lit_Chars val: ' test_must_fail git reset --keep HEAD^ 2>err.log &&\n' span_id: 496 ) (Token id:Id.Lit_Chars val:' test_i18ngrep "middle of a merge" err.log\n' span_id:497) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'"reset --merge HEAD" is ok with pending merge' span_id:519))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:523) (Token id:Id.Lit_Chars val:' git reset --hard third &&\n' span_id:524) (Token id:Id.Lit_Chars val:' test_must_fail git merge branch1 &&\n' span_id:525) (Token id:Id.Lit_Chars val:' git reset --merge HEAD &&\n' span_id:526) (Token id: Id.Lit_Chars val: ' test "$(git rev-parse HEAD)" = "$(git rev-parse third)" &&\n' span_id: 527 ) (Token id:Id.Lit_Chars val:' test -z "$(git diff --cached)" &&\n' span_id:528) (Token id:Id.Lit_Chars val:' test -z "$(git diff)"\n' span_id:529) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'"reset --keep HEAD" fails with pending merge' span_id:551))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:555) (Token id:Id.Lit_Chars val:' git reset --hard third &&\n' span_id:556) (Token id:Id.Lit_Chars val:' test_must_fail git merge branch1 &&\n' span_id:557) (Token id: Id.Lit_Chars val: ' test_must_fail git reset --keep HEAD 2>err.log &&\n' span_id: 558 ) (Token id:Id.Lit_Chars val:' test_i18ngrep "middle of a merge" err.log\n' span_id:559) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'--merge is ok with added/deleted merge' span_id:566))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:570) (Token id:Id.Lit_Chars val:' git reset --hard third &&\n' span_id:571) (Token id:Id.Lit_Chars val:' rm -f file2 &&\n' span_id:572) (Token id: Id.Lit_Chars val: ' test_must_fail git merge branch3 &&\n' span_id: 573 ) (Token id:Id.Lit_Chars val:' ! test -f file2 &&\n' span_id:574) (Token id:Id.Lit_Chars val:' test -f file3 &&\n' span_id:575) (Token id:Id.Lit_Chars val:' git diff --exit-code file3 &&\n' span_id:576) (Token id: Id.Lit_Chars val: ' git diff --exit-code branch3 file3 &&\n' span_id: 577 ) (Token id:Id.Lit_Chars val:' git reset --merge HEAD &&\n' span_id:578) (Token id:Id.Lit_Chars val:' ! test -f file3 &&\n' span_id:579) (Token id:Id.Lit_Chars val:' ! test -f file2 &&\n' span_id:580) (Token id:Id.Lit_Chars val:' git diff --exit-code --cached\n' span_id:581) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'--keep fails with added/deleted merge' span_id:588))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:592) (Token id:Id.Lit_Chars val:' git reset --hard third &&\n' span_id:593) (Token id:Id.Lit_Chars val:' rm -f file2 &&\n' span_id:594) (Token id: Id.Lit_Chars val: ' test_must_fail git merge branch3 &&\n' span_id: 595 ) (Token id:Id.Lit_Chars val:' ! test -f file2 &&\n' span_id:596) (Token id:Id.Lit_Chars val:' test -f file3 &&\n' span_id:597) (Token id:Id.Lit_Chars val:' git diff --exit-code file3 &&\n' span_id:598) (Token id: Id.Lit_Chars val: ' git diff --exit-code branch3 file3 &&\n' span_id: 599 ) (Token id:Id.Lit_Chars val:' test_must_fail git reset --keep HEAD 2>err.log &&\n' span_id:600) (Token id: Id.Lit_Chars val: ' test_i18ngrep "middle of a merge" err.log\n' span_id: 601 ) ) } ) (C {(test_done)}) ] )