]>
Commit | Line | Data |
---|---|---|
a97a96fc EN |
1 | #!/bin/sh |
2 | ||
3 | test_description='miscellaneous rev-list tests' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
8 | echo content1 >wanted_file && | |
9 | echo content2 >unwanted_file && | |
10 | git add wanted_file unwanted_file && | |
f421e029 | 11 | test_tick && |
a97a96fc EN |
12 | git commit -m one |
13 | ' | |
14 | ||
15 | test_expect_success 'rev-list --objects heeds pathspecs' ' | |
16 | git rev-list --objects HEAD -- wanted_file >output && | |
17 | grep wanted_file output && | |
18 | ! grep unwanted_file output | |
19 | ' | |
20 | ||
21 | test_expect_success 'rev-list --objects with pathspecs and deeper paths' ' | |
22 | mkdir foo && | |
23 | >foo/file && | |
24 | git add foo/file && | |
f421e029 | 25 | test_tick && |
a97a96fc EN |
26 | git commit -m two && |
27 | ||
28 | git rev-list --objects HEAD -- foo >output && | |
29 | grep foo/file output && | |
30 | ||
31 | git rev-list --objects HEAD -- foo/file >output && | |
32 | grep foo/file output && | |
33 | ! grep unwanted_file output | |
34 | ' | |
35 | ||
36 | test_expect_success 'rev-list --objects with pathspecs and copied files' ' | |
37 | git checkout --orphan junio-testcase && | |
38 | git rm -rf . && | |
39 | ||
40 | mkdir two && | |
41 | echo frotz >one && | |
42 | cp one two/three && | |
43 | git add one two/three && | |
44 | test_tick && | |
45 | git commit -m that && | |
46 | ||
99094a7a | 47 | ONE=$(git rev-parse HEAD:one) && |
a97a96fc EN |
48 | git rev-list --objects HEAD two >output && |
49 | grep "$ONE two/three" output && | |
50 | ! grep one output | |
51 | ' | |
52 | ||
42357b4e ES |
53 | test_expect_success 'rev-list --objects --no-object-names has no space/names' ' |
54 | git rev-list --objects --no-object-names HEAD >output && | |
55 | ! grep wanted_file output && | |
56 | ! grep unwanted_file output && | |
57 | ! grep " " output | |
58 | ' | |
59 | ||
60 | test_expect_success 'rev-list --objects --no-object-names works with cat-file' ' | |
61 | git rev-list --objects --no-object-names --all >list-output && | |
62 | git cat-file --batch-check <list-output >cat-output && | |
63 | ! grep missing cat-output | |
64 | ' | |
65 | ||
66 | test_expect_success '--no-object-names and --object-names are last-one-wins' ' | |
67 | git rev-list --objects --no-object-names --object-names --all >output && | |
68 | grep wanted_file output && | |
69 | git rev-list --objects --object-names --no-object-names --all >output && | |
70 | ! grep wanted_file output | |
71 | ' | |
72 | ||
895c5ba3 | 73 | test_expect_success 'rev-list A..B and rev-list ^A B are the same' ' |
f421e029 | 74 | test_tick && |
895c5ba3 JH |
75 | git commit --allow-empty -m another && |
76 | git tag -a -m "annotated" v1.0 && | |
77 | git rev-list --objects ^v1.0^ v1.0 >expect && | |
78 | git rev-list --objects v1.0^..v1.0 >actual && | |
79 | test_cmp expect actual | |
80 | ' | |
81 | ||
2ac5e447 JH |
82 | test_expect_success 'propagate uninteresting flag down correctly' ' |
83 | git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual && | |
d3c6751b | 84 | test_must_be_empty actual |
2ac5e447 JH |
85 | ' |
86 | ||
a7435286 JH |
87 | test_expect_success 'symleft flag bit is propagated down from tag' ' |
88 | git log --format="%m %s" --left-right v1.0...master >actual && | |
89 | cat >expect <<-\EOF && | |
a7435286 JH |
90 | < another |
91 | < that | |
f421e029 JK |
92 | > two |
93 | > one | |
a7435286 JH |
94 | EOF |
95 | test_cmp expect actual | |
96 | ' | |
97 | ||
4fe10219 JK |
98 | test_expect_success 'rev-list can show index objects' ' |
99 | # Of the blobs and trees in the index, note: | |
100 | # | |
101 | # - we do not show two/three, because it is the | |
102 | # same blob as "one", and we show objects only once | |
103 | # | |
104 | # - we do show the tree "two", because it has a valid cache tree | |
105 | # from the last commit | |
106 | # | |
107 | # - we do not show the root tree; since we updated the index, it | |
108 | # does not have a valid cache tree | |
109 | # | |
4fe10219 | 110 | echo only-in-index >only-in-index && |
b4cfcde4 | 111 | test_when_finished "git reset --hard" && |
5db24dcf | 112 | rev1=$(git rev-parse HEAD:one) && |
113 | rev2=$(git rev-parse HEAD:two) && | |
114 | revi=$(git hash-object only-in-index) && | |
115 | cat >expect <<-EOF && | |
116 | $rev1 one | |
117 | $revi only-in-index | |
118 | $rev2 two | |
119 | EOF | |
4fe10219 JK |
120 | git add only-in-index && |
121 | git rev-list --objects --indexed-objects >actual && | |
122 | test_cmp expect actual | |
123 | ' | |
124 | ||
b4cfcde4 JK |
125 | test_expect_success 'rev-list can negate index objects' ' |
126 | git rev-parse HEAD >expect && | |
127 | git rev-list -1 --objects HEAD --not --indexed-objects >actual && | |
128 | test_cmp expect actual | |
129 | ' | |
130 | ||
0fe305a5 AL |
131 | test_expect_success '--bisect and --first-parent can be combined' ' |
132 | git rev-list --bisect --first-parent HEAD | |
f88851c6 KD |
133 | ' |
134 | ||
98985c69 JK |
135 | test_expect_success '--header shows a NUL after each commit' ' |
136 | # We know that there is no Q in the true payload; names and | |
137 | # addresses of the authors and the committers do not have | |
138 | # any, and object names or header names do not, either. | |
139 | git rev-list --header --max-count=2 HEAD | | |
140 | nul_to_q | | |
141 | grep "^Q" >actual && | |
142 | cat >expect <<-EOF && | |
143 | Q$(git rev-parse HEAD~1) | |
144 | Q | |
145 | EOF | |
146 | test_cmp expect actual | |
147 | ' | |
148 | ||
19e8789b JK |
149 | test_expect_success 'rev-list --end-of-options' ' |
150 | git update-ref refs/heads/--output=yikes HEAD && | |
151 | git rev-list --end-of-options --output=yikes >actual && | |
152 | test_path_is_missing yikes && | |
153 | git rev-list HEAD >expect && | |
154 | test_cmp expect actual | |
155 | ' | |
156 | ||
55cb10f9 JK |
157 | test_expect_success 'rev-list --count' ' |
158 | count=$(git rev-list --count HEAD) && | |
159 | git rev-list HEAD >actual && | |
160 | test_line_count = $count actual | |
161 | ' | |
162 | ||
163 | test_expect_success 'rev-list --count --objects' ' | |
164 | count=$(git rev-list --count --objects HEAD) && | |
165 | git rev-list --objects HEAD >actual && | |
166 | test_line_count = $count actual | |
167 | ' | |
168 | ||
a97a96fc | 169 | test_done |