get_urlmatch: avoid useless strbuf write
[alt-git.git] / t / t2203-add-intent.sh
blob7c641bfaf4565a97942a91793370da0ca6285fc3
1 #!/bin/sh
3 test_description='Intent to add'
5 . ./test-lib.sh
7 test_expect_success 'intent to add' '
8 test_commit 1 &&
9 git rm 1.t &&
10 echo hello >1.t &&
11 echo hello >file &&
12 echo hello >elif &&
13 git add -N file &&
14 git add elif &&
15 git add -N 1.t
18 test_expect_success 'git status' '
19 git status --porcelain | grep -v actual >actual &&
20 cat >expect <<-\EOF &&
21 DA 1.t
22 A elif
23 A file
24 EOF
25 test_cmp expect actual
28 test_expect_success 'check result of "add -N"' '
29 git ls-files -s file >actual &&
30 empty=$(git hash-object --stdin </dev/null) &&
31 echo "100644 $empty 0 file" >expect &&
32 test_cmp expect actual
35 test_expect_success 'intent to add is just an ordinary empty blob' '
36 git add -u &&
37 git ls-files -s file >actual &&
38 git ls-files -s elif | sed -e "s/elif/file/" >expect &&
39 test_cmp expect actual
42 test_expect_success 'intent to add does not clobber existing paths' '
43 git add -N file elif &&
44 empty=$(git hash-object --stdin </dev/null) &&
45 git ls-files -s >actual &&
46 ! grep "$empty" actual
49 test_expect_success 'i-t-a entry is simply ignored' '
50 test_tick &&
51 git commit -a -m initial &&
52 git reset --hard &&
54 echo xyzzy >rezrov &&
55 echo frotz >nitfol &&
56 git add rezrov &&
57 git add -N nitfol &&
58 git commit -m second &&
59 test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
60 test $(git diff --name-only HEAD -- nitfol | wc -l) = 0 &&
61 test $(git diff --name-only -- nitfol | wc -l) = 1
64 test_expect_success 'can commit with an unrelated i-t-a entry in index' '
65 git reset --hard &&
66 echo bozbar >rezrov &&
67 echo frotz >nitfol &&
68 git add rezrov &&
69 git add -N nitfol &&
70 git commit -m partial rezrov
73 test_expect_success 'can "commit -a" with an i-t-a entry' '
74 git reset --hard &&
75 : >nitfol &&
76 git add -N nitfol &&
77 git commit -a -m all
80 test_expect_success 'cache-tree invalidates i-t-a paths' '
81 git reset --hard &&
82 mkdir dir &&
83 : >dir/foo &&
84 git add dir/foo &&
85 git commit -m foo &&
87 : >dir/bar &&
88 git add -N dir/bar &&
89 git diff --cached --name-only >actual &&
90 >expect &&
91 test_cmp expect actual &&
93 git write-tree >/dev/null &&
95 git diff --cached --name-only >actual &&
96 >expect &&
97 test_cmp expect actual
100 test_done