(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: { (SQ <'git checkout-index --temp test.\n'> <'\n'> <'With --temp flag, git checkout-index writes to temporary merge files\n'> <'rather than the tracked path.'> ) } spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (C {<test_expect_success>} {(SQ <setup>)} { (SQ <'\n'> <'\tmkdir asubdir &&\n'> <'\techo tree1path0 >path0 &&\n'> <'\techo tree1path1 >path1 &&\n'> <'\techo tree1path3 >path3 &&\n'> <'\techo tree1path4 >path4 &&\n'> <'\techo tree1asubdir/path5 >asubdir/path5 &&\n'> <'\tgit update-index --add path0 path1 path3 path4 asubdir/path5 &&\n'> <'\tt1=$(git write-tree) &&\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\techo tree2path0 >path0 &&\n'> <'\techo tree2path1 >path1 &&\n'> <'\techo tree2path2 >path2 &&\n'> <'\techo tree2path4 >path4 &&\n'> <'\tgit update-index --add path0 path1 path2 path4 &&\n'> <'\tt2=$(git write-tree) &&\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\techo tree2path0 >path0 &&\n'> <'\techo tree3path1 >path1 &&\n'> <'\techo tree3path2 >path2 &&\n'> <'\techo tree3path3 >path3 &&\n'> <'\tgit update-index --add path0 path1 path2 path3 &&\n'> <'\tt3=$(git write-tree)\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout one stage 0 to temporary file'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\tgit read-tree $t1 &&\n'> <'\tgit checkout-index --temp -- path1 >actual &&\n'> <'\ttest_line_count = 1 actual &&\n'> <'\ttest $(cut "-d\t" -f2 actual) = path1 &&\n'> <'\tp=$(cut "-d\t" -f1 actual) &&\n'> <'\ttest -f $p &&\n'> <'\ttest $(cat $p) = tree1path1\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout all stage 0 to temporary files'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\tgit read-tree $t1 &&\n'> <'\tgit checkout-index -a --temp >actual &&\n'> <'\ttest_line_count = 5 actual &&\n'> <'\tfor f in path0 path1 path3 path4 asubdir/path5\n'> <'\tdo\n'> <'\t\ttest $(grep $f actual | cut "-d\t" -f2) = $f &&\n'> <'\t\tp=$(grep $f actual | cut "-d\t" -f1) &&\n'> <'\t\ttest -f $p &&\n'> <'\t\ttest $(cat $p) = tree1$f\n'> <'\tdone\n'> ) } ) (C {<test_expect_success>} {(SQ <'setup 3-way merge'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\tgit read-tree -m $t1 $t2 $t3\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout one stage 2 to temporary file'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index --stage=2 --temp -- path1 >actual &&\n'> <'\ttest_line_count = 1 actual &&\n'> <'\ttest $(cut "-d\t" -f2 actual) = path1 &&\n'> <'\tp=$(cut "-d\t" -f1 actual) &&\n'> <'\ttest -f $p &&\n'> <'\ttest $(cat $p) = tree2path1\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout all stage 2 to temporary files'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index --all --stage=2 --temp >actual &&\n'> <'\ttest_line_count = 3 actual &&\n'> <'\tfor f in path1 path2 path4\n'> <'\tdo\n'> <'\t\ttest $(grep $f actual | cut "-d\t" -f2) = $f &&\n'> <'\t\tp=$(grep $f actual | cut "-d\t" -f1) &&\n'> <'\t\ttest -f $p &&\n'> <'\t\ttest $(cat $p) = tree2$f\n'> <'\tdone\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout all stages/one file to nothing'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index --stage=all --temp -- path0 >actual &&\n'> <'\ttest_line_count = 0 actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout all stages/one file to temporary files'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index --stage=all --temp -- path1 >actual &&\n'> <'\ttest_line_count = 1 actual &&\n'> <'\ttest $(cut "-d\t" -f2 actual) = path1 &&\n'> <'\tcut "-d\t" -f1 actual | (read s1 s2 s3 &&\n'> <'\ttest -f $s1 &&\n'> <'\ttest -f $s2 &&\n'> <'\ttest -f $s3 &&\n'> <'\ttest $(cat $s1) = tree1path1 &&\n'> <'\ttest $(cat $s2) = tree2path1 &&\n'> <'\ttest $(cat $s3) = tree3path1)\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout some stages/one file to temporary files'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index --stage=all --temp -- path2 >actual &&\n'> <'\ttest_line_count = 1 actual &&\n'> <'\ttest $(cut "-d\t" -f2 actual) = path2 &&\n'> <'\tcut "-d\t" -f1 actual | (read s1 s2 s3 &&\n'> <'\ttest $s1 = . &&\n'> <'\ttest -f $s2 &&\n'> <'\ttest -f $s3 &&\n'> <'\ttest $(cat $s2) = tree2path2 &&\n'> <'\ttest $(cat $s3) = tree3path2)\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout all stages/all files to temporary files'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual &&\n'> <'\tgit checkout-index -a --stage=all --temp >actual &&\n'> <'\ttest_line_count = 5 actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'-- path0: no entry'>)} {(SQ <'\n'> <'\ttest x$(grep path0 actual | cut "-d\t" -f2) = x\n'>)} ) (C {<test_expect_success>} {(SQ <'-- path1: all 3 stages'>)} { (SQ <'\n'> <'\ttest $(grep path1 actual | cut "-d\t" -f2) = path1 &&\n'> <'\tgrep path1 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\ttest -f $s1 &&\n'> <'\ttest -f $s2 &&\n'> <'\ttest -f $s3 &&\n'> <'\ttest $(cat $s1) = tree1path1 &&\n'> <'\ttest $(cat $s2) = tree2path1 &&\n'> <'\ttest $(cat $s3) = tree3path1)\n'> ) } ) (C {<test_expect_success>} {(SQ <'-- path2: no stage 1, have stage 2 and 3'>)} { (SQ <'\n'> <'\ttest $(grep path2 actual | cut "-d\t" -f2) = path2 &&\n'> <'\tgrep path2 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\ttest $s1 = . &&\n'> <'\ttest -f $s2 &&\n'> <'\ttest -f $s3 &&\n'> <'\ttest $(cat $s2) = tree2path2 &&\n'> <'\ttest $(cat $s3) = tree3path2)\n'> ) } ) (C {<test_expect_success>} {(SQ <'-- path3: no stage 2, have stage 1 and 3'>)} { (SQ <'\n'> <'\ttest $(grep path3 actual | cut "-d\t" -f2) = path3 &&\n'> <'\tgrep path3 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\ttest -f $s1 &&\n'> <'\ttest $s2 = . &&\n'> <'\ttest -f $s3 &&\n'> <'\ttest $(cat $s1) = tree1path3 &&\n'> <'\ttest $(cat $s3) = tree3path3)\n'> ) } ) (C {<test_expect_success>} {(SQ <'-- path4: no stage 3, have stage 1 and 3'>)} { (SQ <'\n'> <'\ttest $(grep path4 actual | cut "-d\t" -f2) = path4 &&\n'> <'\tgrep path4 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\ttest -f $s1 &&\n'> <'\ttest -f $s2 &&\n'> <'\ttest $s3 = . &&\n'> <'\ttest $(cat $s1) = tree1path4 &&\n'> <'\ttest $(cat $s2) = tree2path4)\n'> ) } ) (C {<test_expect_success>} {(SQ <'-- asubdir/path5: no stage 2 and 3 have stage 1'>)} { (SQ <'\n'> <'\ttest $(grep asubdir/path5 actual | cut "-d\t" -f2) = asubdir/path5 &&\n'> <'\tgrep asubdir/path5 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\ttest -f $s1 &&\n'> <'\ttest $s2 = . &&\n'> <'\ttest $s3 = . &&\n'> <'\ttest $(cat $s1) = tree1asubdir/path5)\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout --temp within subdir'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd asubdir &&\n'> <'\t\tgit checkout-index -a --stage=all >actual &&\n'> <'\t\ttest_line_count = 1 actual &&\n'> <'\t\ttest $(grep path5 actual | cut "-d\t" -f2) = path5 &&\n'> <'\t\tgrep path5 actual | cut "-d\t" -f1 | (read s1 s2 s3 &&\n'> <'\t\ttest -f ../$s1 &&\n'> <'\t\ttest $s2 = . &&\n'> <'\t\ttest $s3 = . &&\n'> <'\t\ttest $(cat ../$s1) = tree1asubdir/path5)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'checkout --temp symlink'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\ttest_ln_s_add path7 path6 &&\n'> <'\tgit checkout-index --temp -a >actual &&\n'> <'\ttest_line_count = 1 actual &&\n'> <'\ttest $(cut "-d\t" -f2 actual) = path6 &&\n'> <'\tp=$(cut "-d\t" -f1 actual) &&\n'> <'\ttest -f $p &&\n'> <'\ttest $(cat $p) = path7\n'> ) } ) (C {<test_expect_success>} {(SQ <'emit well-formed relative path'>)} { (SQ <'\n'> <'\trm -f path* .merge_* actual .git/index &&\n'> <'\t>path0123456789 &&\n'> <'\tgit update-index --add path0123456789 &&\n'> <'\t(\n'> <'\t\tcd asubdir &&\n'> <'\t\tgit checkout-index --temp -- ../path0123456789 >actual &&\n'> <'\t\ttest_line_count = 1 actual &&\n'> <'\t\ttest $(cut "-d\t" -f2 actual) = ../path0123456789\n'> <'\t)\n'> ) } ) (C {<test_done>}) ] )