l10n: bg.po: Updated Bulgarian translation (5211t)
[git/debian.git] / t / t2022-checkout-paths.sh
blobc49ba7f9bd4fe0c6f8f88fbe5a0722b2d6337ac7
1 #!/bin/sh
3 test_description='checkout $tree -- $paths'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 test_expect_success setup '
10 mkdir dir &&
11 >dir/main &&
12 echo common >dir/common &&
13 git add dir/main dir/common &&
14 test_tick && git commit -m "main has dir/main" &&
15 git checkout -b next &&
16 git mv dir/main dir/next0 &&
17 echo next >dir/next1 &&
18 git add dir &&
19 test_tick && git commit -m "next has dir/next but not dir/main"
22 test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' '
23 git checkout next &&
24 git reset --hard &&
25 rm dir/next0 &&
26 cat dir/common >expect.common &&
27 echo modified >expect.next1 &&
28 cat expect.next1 >dir/next1 &&
29 echo untracked >expect.next2 &&
30 cat expect.next2 >dir/next2 &&
32 git checkout main dir &&
34 test_cmp expect.common dir/common &&
35 test_path_is_file dir/main &&
36 git diff --exit-code main dir/main &&
38 test_path_is_missing dir/next0 &&
39 test_cmp expect.next1 dir/next1 &&
40 test_path_is_file dir/next2 &&
41 test_must_fail git ls-files --error-unmatch dir/next2 &&
42 test_cmp expect.next2 dir/next2
45 test_expect_success 'do not touch unmerged entries matching $path but not in $tree' '
46 git checkout next &&
47 git reset --hard &&
49 cat dir/common >expect.common &&
50 EMPTY_SHA1=$(git hash-object -w --stdin </dev/null) &&
51 git rm dir/next0 &&
52 cat >expect.next0 <<-EOF &&
53 100644 $EMPTY_SHA1 1 dir/next0
54 100644 $EMPTY_SHA1 2 dir/next0
55 EOF
56 git update-index --index-info <expect.next0 &&
58 git checkout main dir &&
60 test_cmp expect.common dir/common &&
61 test_path_is_file dir/main &&
62 git diff --exit-code main dir/main &&
63 git ls-files -s dir/next0 >actual.next0 &&
64 test_cmp expect.next0 actual.next0
67 test_expect_success 'do not touch files that are already up-to-date' '
68 git reset --hard &&
69 echo one >file1 &&
70 echo two >file2 &&
71 git add file1 file2 &&
72 git commit -m base &&
73 echo modified >file1 &&
74 test-tool chmtime =1000000000 file2 &&
75 git update-index -q --refresh &&
76 git checkout HEAD -- file1 file2 &&
77 echo one >expect &&
78 test_cmp expect file1 &&
79 echo "1000000000" >expect &&
80 test-tool chmtime --get file2 >actual &&
81 test_cmp expect actual
84 test_expect_success 'checkout HEAD adds deleted intent-to-add file back to index' '
85 echo "nonempty" >nonempty &&
86 >empty &&
87 git add nonempty empty &&
88 git commit -m "create files to be deleted" &&
89 git rm --cached nonempty empty &&
90 git add -N nonempty empty &&
91 git checkout HEAD nonempty empty &&
92 git diff --cached --exit-code
95 test_done