3 test_description='checkout $tree -- $paths'
6 test_expect_success setup '
9 echo common >dir/common &&
10 git add dir/master dir/common &&
11 test_tick && git commit -m "master has dir/master" &&
12 git checkout -b next &&
13 git mv dir/master dir/next0 &&
14 echo next >dir/next1 &&
16 test_tick && git commit -m "next has dir/next but not dir/master"
19 test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' '
23 cat dir/common >expect.common &&
24 echo modified >expect.next1 &&
25 cat expect.next1 >dir/next1 &&
26 echo untracked >expect.next2 &&
27 cat expect.next2 >dir/next2 &&
29 git checkout master dir &&
31 test_cmp expect.common dir/common &&
32 test_path_is_file dir/master &&
33 git diff --exit-code master dir/master &&
35 test_path_is_missing dir/next0 &&
36 test_cmp expect.next1 dir/next1 &&
37 test_path_is_file dir/next2 &&
38 test_must_fail git ls-files --error-unmatch dir/next2 &&
39 test_cmp expect.next2 dir/next2
42 test_expect_success 'do not touch unmerged entries matching $path but not in $tree' '
46 cat dir/common >expect.common &&
47 EMPTY_SHA1=$(git hash-object -w --stdin </dev/null) &&
49 cat >expect.next0 <<-EOF &&
50 100644 $EMPTY_SHA1 1 dir/next0
51 100644 $EMPTY_SHA1 2 dir/next0
53 git update-index --index-info <expect.next0 &&
55 git checkout master dir &&
57 test_cmp expect.common dir/common &&
58 test_path_is_file dir/master &&
59 git diff --exit-code master dir/master &&
60 git ls-files -s dir/next0 >actual.next0 &&
61 test_cmp expect.next0 actual.next0