#!/bin/sh # # Copyright (c) 2010 Christian Couder # global test_description := ''Tests to check that "reset" options follow a known table'' source ./test-lib.sh test_expect_success 'creating initial commits' ' test_commit E file1 && test_commit D file1 && test_commit C file1 ' while read W1 I1 H1 T opt W2 I2 H2 { test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" ' git reset --hard C && if test "$I1" != "$H1" then echo "$I1" >file1 && git add file1 fi && if test "$W1" != "$I1" then echo "$W1" >file1 fi && if test "$W2" != "XXXXX" then git reset --$opt $T && test "$(cat file1)" = "$W2" && git checkout-index -f -- file1 && test "$(cat file1)" = "$I2" && git checkout -f HEAD -- file1 && test "$(cat file1)" = "$H2" else test_must_fail git reset --$opt $T fi ' } <<\EOF test_expect_success 'setting up branches to test with unmerged entries' ' git reset --hard C && git branch branch1 && git branch branch2 && git checkout branch1 && test_commit B1 file1 && git checkout branch2 && test_commit B file1 ' while read W1 I1 H1 T opt W2 I2 H2 { test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" ' git reset --hard B && test_must_fail git merge branch1 && cat file1 >X_file1 && if test "$W2" != "XXXXX" then git reset --$opt $T && if test "$W2" = "X" then test_cmp file1 X_file1 else test "$(cat file1)" = "$W2" fi && git checkout-index -f -- file1 && test "$(cat file1)" = "$I2" && git checkout -f HEAD -- file1 && test "$(cat file1)" = "$H2" else test_must_fail git reset --$opt $T fi ' } <<\EOF test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Tests to check that \"reset\" options follow a known table">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"creating initial commits">)} { (SQ <"\n"> <" test_commit E file1 &&\n"> <" test_commit D file1 &&\n"> <" test_commit C file1\n"> ) } ) (While cond: [(C {(read)} {(W1)} {(I1)} {(H1)} {(T)} {(opt)} {(W2)} {(I2)} {(H2)})] body: (DoGroup children: [ (C {(test_expect_success)} { (DQ ("check: ") ($ VSub_Name "$W1") (" ") ($ VSub_Name "$I1") (" ") ($ VSub_Name "$H1") (" ") ($ VSub_Name "$T") (" --") ($ VSub_Name "$opt") (" ") ($ VSub_Name "$W2") (" ") ($ VSub_Name "$I2") (" ") ($ VSub_Name "$H2") ) } { (SQ <"\n"> <"\tgit reset --hard C &&\n"> <"\tif test \"$I1\" != \"$H1\"\n"> <"\tthen\n"> <"\t echo \"$I1\" >file1 &&\n"> <"\t git add file1\n"> <"\tfi &&\n"> <"\tif test \"$W1\" != \"$I1\"\n"> <"\tthen\n"> <"\t echo \"$W1\" >file1\n"> <"\tfi &&\n"> <"\tif test \"$W2\" != \"XXXXX\"\n"> <"\tthen\n"> <"\t git reset --$opt $T &&\n"> <"\t test \"$(cat file1)\" = \"$W2\" &&\n"> <"\t git checkout-index -f -- file1 &&\n"> <"\t test \"$(cat file1)\" = \"$I2\" &&\n"> <"\t git checkout -f HEAD -- file1 &&\n"> <"\t test \"$(cat file1)\" = \"$H2\"\n"> <"\telse\n"> <"\t test_must_fail git reset --$opt $T\n"> <"\tfi\n"> <" "> ) } ) ] spids: [59 109] ) redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: {("A B C D soft A B D\n") ("A B C D mixed A D D\n") ("A B C D hard D D D\n") ("A B C D merge XXXXX\n") ("A B C D keep XXXXX\n") ("A B C C soft A B C\n") ("A B C C mixed A C C\n") ("A B C C hard C C C\n") ("A B C C merge XXXXX\n") ("A B C C keep A C C\n") ("B B C D soft B B D\n") ("B B C D mixed B D D\n") ("B B C D hard D D D\n") ("B B C D merge D D D\n") ("B B C D keep XXXXX\n") ("B B C C soft B B C\n") ("B B C C mixed B C C\n") ("B B C C hard C C C\n") ("B B C C merge C C C\n") ("B B C C keep B C C\n") ("B C C D soft B C D\n") ("B C C D mixed B D D\n") ("B C C D hard D D D\n") ("B C C D merge XXXXX\n") ("B C C D keep XXXXX\n") ("B C C C soft B C C\n") ("B C C C mixed B C C\n") ("B C C C hard C C C\n") ("B C C C merge B C C\n") ("B C C C keep B C C\n") } do_expansion: False here_end: EOF was_filled: True spids: [111] ) ] ) (C {(test_expect_success)} {(SQ <"setting up branches to test with unmerged entries">)} { (SQ <"\n"> <" git reset --hard C &&\n"> <" git branch branch1 &&\n"> <" git branch branch2 &&\n"> <" git checkout branch1 &&\n"> <" test_commit B1 file1 &&\n"> <" git checkout branch2 &&\n"> <" test_commit B file1\n"> ) } ) (While cond: [(C {(read)} {(W1)} {(I1)} {(H1)} {(T)} {(opt)} {(W2)} {(I2)} {(H2)})] body: (DoGroup children: [ (C {(test_expect_success)} { (DQ ("check: ") ($ VSub_Name "$W1") (" ") ($ VSub_Name "$I1") (" ") ($ VSub_Name "$H1") (" ") ($ VSub_Name "$T") (" --") ($ VSub_Name "$opt") (" ") ($ VSub_Name "$W2") (" ") ($ VSub_Name "$I2") (" ") ($ VSub_Name "$H2") ) } { (SQ <"\n"> <"\tgit reset --hard B &&\n"> <"\ttest_must_fail git merge branch1 &&\n"> <"\tcat file1 >X_file1 &&\n"> <"\tif test \"$W2\" != \"XXXXX\"\n"> <"\tthen\n"> <"\t git reset --$opt $T &&\n"> <"\t if test \"$W2\" = \"X\"\n"> <"\t then\n"> <"\t\ttest_cmp file1 X_file1\n"> <"\t else\n"> <"\t\ttest \"$(cat file1)\" = \"$W2\"\n"> <"\t fi &&\n"> <"\t git checkout-index -f -- file1 &&\n"> <"\t test \"$(cat file1)\" = \"$I2\" &&\n"> <"\t git checkout -f HEAD -- file1 &&\n"> <"\t test \"$(cat file1)\" = \"$H2\"\n"> <"\telse\n"> <"\t test_must_fail git reset --$opt $T\n"> <"\tfi\n"> <" "> ) } ) ] spids: [154 202] ) redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: {("X U B C soft XXXXX\n") ("X U B C mixed X C C\n") ("X U B C hard C C C\n") ("X U B C merge C C C\n") ("X U B C keep XXXXX\n") ("X U B B soft XXXXX\n") ("X U B B mixed X B B\n") ("X U B B hard B B B\n") ("X U B B merge B B B\n") ("X U B B keep XXXXX\n") } do_expansion: False here_end: EOF was_filled: True spids: [204] ) ] ) (C {(test_done)}) ] )