]>
Commit | Line | Data |
---|---|---|
15af58c1 SB |
1 | #!/bin/sh |
2 | ||
3 | test_description='test finding specific blobs in the revision walking' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup ' ' | |
7 | git commit --allow-empty -m "empty initial commit" && | |
8 | ||
9 | echo "Hello, world!" >greeting && | |
10 | git add greeting && | |
11 | git commit -m "add the greeting blob" && # borrowed from Git from the Bottom Up | |
12 | git tag -m "the blob" greeting $(git rev-parse HEAD:greeting) && | |
13 | ||
14 | echo asdf >unrelated && | |
15 | git add unrelated && | |
16 | git commit -m "unrelated history" && | |
17 | ||
18 | git revert HEAD^ && | |
19 | ||
20 | git commit --allow-empty -m "another unrelated commit" | |
21 | ' | |
22 | ||
23 | test_expect_success 'find the greeting blob' ' | |
24 | cat >expect <<-EOF && | |
25 | Revert "add the greeting blob" | |
26 | add the greeting blob | |
27 | EOF | |
28 | ||
29 | git log --format=%s --find-object=greeting^{blob} >actual && | |
30 | ||
31 | test_cmp expect actual | |
32 | ' | |
33 | ||
34 | test_expect_success 'setup a tree' ' | |
35 | mkdir a && | |
36 | echo asdf >a/file && | |
37 | git add a/file && | |
38 | git commit -m "add a file in a subdirectory" | |
39 | ' | |
40 | ||
41 | test_expect_success 'find a tree' ' | |
42 | cat >expect <<-EOF && | |
43 | add a file in a subdirectory | |
44 | EOF | |
45 | ||
46 | git log --format=%s -t --find-object=HEAD:a >actual && | |
47 | ||
48 | test_cmp expect actual | |
49 | ' | |
50 | ||
51 | test_expect_success 'setup a submodule' ' | |
52 | test_create_repo sub && | |
53 | test_commit -C sub sub && | |
54 | git submodule add ./sub sub && | |
55 | git commit -a -m "add sub" | |
56 | ' | |
57 | ||
58 | test_expect_success 'find a submodule' ' | |
59 | cat >expect <<-EOF && | |
60 | add sub | |
61 | EOF | |
62 | ||
63 | git log --format=%s --find-object=HEAD:sub >actual && | |
64 | ||
65 | test_cmp expect actual | |
66 | ' | |
67 | ||
957876f1 JK |
68 | test_expect_success 'set up merge tests' ' |
69 | test_commit base && | |
70 | ||
71 | git checkout -b boring base^ && | |
72 | echo boring >file && | |
73 | git add file && | |
74 | git commit -m boring && | |
75 | ||
76 | git checkout -b interesting base^ && | |
77 | echo interesting >file && | |
78 | git add file && | |
79 | git commit -m interesting && | |
80 | ||
81 | blob=$(git rev-parse interesting:file) | |
82 | ' | |
83 | ||
84 | test_expect_success 'detect merge which introduces blob' ' | |
85 | git checkout -B merge base && | |
86 | git merge --no-commit boring && | |
87 | echo interesting >file && | |
88 | git commit -am "introduce blob" && | |
89 | git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual && | |
90 | cat >expect <<-\EOF && | |
91 | introduce blob | |
92 | ||
93 | AM file | |
94 | EOF | |
95 | test_cmp expect actual | |
96 | ' | |
97 | ||
98 | test_expect_success 'detect merge which removes blob' ' | |
99 | git checkout -B merge interesting && | |
100 | git merge --no-commit base && | |
101 | echo boring >file && | |
102 | git commit -am "remove blob" && | |
103 | git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual && | |
104 | cat >expect <<-\EOF && | |
105 | remove blob | |
106 | ||
107 | MA file | |
108 | EOF | |
109 | test_cmp expect actual | |
110 | ' | |
111 | ||
112 | test_expect_success 'do not detect merge that does not touch blob' ' | |
113 | git checkout -B merge interesting && | |
114 | git merge -m "untouched blob" base && | |
115 | git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual && | |
116 | cat >expect <<-\EOF && | |
117 | untouched blob | |
118 | ||
119 | EOF | |
120 | test_cmp expect actual | |
121 | ' | |
122 | ||
15af58c1 | 123 | test_done |