]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6000-rev-list-misc.sh
t4014: make output-directory tests self-contained
[thirdparty/git.git] / t / t6000-rev-list-misc.sh
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 &&
11 git commit -m one
12 '
13
14 test_expect_success 'rev-list --objects heeds pathspecs' '
15 git rev-list --objects HEAD -- wanted_file >output &&
16 grep wanted_file output &&
17 ! grep unwanted_file output
18 '
19
20 test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
21 mkdir foo &&
22 >foo/file &&
23 git add foo/file &&
24 git commit -m two &&
25
26 git rev-list --objects HEAD -- foo >output &&
27 grep foo/file output &&
28
29 git rev-list --objects HEAD -- foo/file >output &&
30 grep foo/file output &&
31 ! grep unwanted_file output
32 '
33
34 test_expect_success 'rev-list --objects with pathspecs and copied files' '
35 git checkout --orphan junio-testcase &&
36 git rm -rf . &&
37
38 mkdir two &&
39 echo frotz >one &&
40 cp one two/three &&
41 git add one two/three &&
42 test_tick &&
43 git commit -m that &&
44
45 ONE=$(git rev-parse HEAD:one) &&
46 git rev-list --objects HEAD two >output &&
47 grep "$ONE two/three" output &&
48 ! grep one output
49 '
50
51 test_expect_success 'rev-list --objects --no-object-names has no space/names' '
52 git rev-list --objects --no-object-names HEAD >output &&
53 ! grep wanted_file output &&
54 ! grep unwanted_file output &&
55 ! grep " " output
56 '
57
58 test_expect_success 'rev-list --objects --no-object-names works with cat-file' '
59 git rev-list --objects --no-object-names --all >list-output &&
60 git cat-file --batch-check <list-output >cat-output &&
61 ! grep missing cat-output
62 '
63
64 test_expect_success '--no-object-names and --object-names are last-one-wins' '
65 git rev-list --objects --no-object-names --object-names --all >output &&
66 grep wanted_file output &&
67 git rev-list --objects --object-names --no-object-names --all >output &&
68 ! grep wanted_file output
69 '
70
71 test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
72 git commit --allow-empty -m another &&
73 git tag -a -m "annotated" v1.0 &&
74 git rev-list --objects ^v1.0^ v1.0 >expect &&
75 git rev-list --objects v1.0^..v1.0 >actual &&
76 test_cmp expect actual
77 '
78
79 test_expect_success 'propagate uninteresting flag down correctly' '
80 git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual &&
81 test_must_be_empty actual
82 '
83
84 test_expect_success 'symleft flag bit is propagated down from tag' '
85 git log --format="%m %s" --left-right v1.0...master >actual &&
86 cat >expect <<-\EOF &&
87 > two
88 > one
89 < another
90 < that
91 EOF
92 test_cmp expect actual
93 '
94
95 test_expect_success 'rev-list can show index objects' '
96 # Of the blobs and trees in the index, note:
97 #
98 # - we do not show two/three, because it is the
99 # same blob as "one", and we show objects only once
100 #
101 # - we do show the tree "two", because it has a valid cache tree
102 # from the last commit
103 #
104 # - we do not show the root tree; since we updated the index, it
105 # does not have a valid cache tree
106 #
107 cat >expect <<-\EOF &&
108 8e4020bb5a8d8c873b25de15933e75cc0fc275df one
109 d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index
110 9200b628cf9dc883a85a7abc8d6e6730baee589c two
111 EOF
112 echo only-in-index >only-in-index &&
113 test_when_finished "git reset --hard" &&
114 git add only-in-index &&
115 git rev-list --objects --indexed-objects >actual &&
116 test_cmp expect actual
117 '
118
119 test_expect_success 'rev-list can negate index objects' '
120 git rev-parse HEAD >expect &&
121 git rev-list -1 --objects HEAD --not --indexed-objects >actual &&
122 test_cmp expect actual
123 '
124
125 test_expect_success '--bisect and --first-parent can not be combined' '
126 test_must_fail git rev-list --bisect --first-parent HEAD
127 '
128
129 test_expect_success '--header shows a NUL after each commit' '
130 # We know that there is no Q in the true payload; names and
131 # addresses of the authors and the committers do not have
132 # any, and object names or header names do not, either.
133 git rev-list --header --max-count=2 HEAD |
134 nul_to_q |
135 grep "^Q" >actual &&
136 cat >expect <<-EOF &&
137 Q$(git rev-parse HEAD~1)
138 Q
139 EOF
140 test_cmp expect actual
141 '
142
143 test_done