]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6000-rev-list-misc.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t6000-rev-list-misc.sh
CommitLineData
a97a96fc
EN
1#!/bin/sh
2
3test_description='miscellaneous rev-list tests'
4
5. ./test-lib.sh
6
7test_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
14test_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
20test_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
34test_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
99094a7a 45 ONE=$(git rev-parse HEAD:one) &&
a97a96fc
EN
46 git rev-list --objects HEAD two >output &&
47 grep "$ONE two/three" output &&
48 ! grep one output
49'
50
42357b4e
ES
51test_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
58test_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
64test_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
895c5ba3
JH
71test_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
2ac5e447
JH
79test_expect_success 'propagate uninteresting flag down correctly' '
80 git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual &&
d3c6751b 81 test_must_be_empty actual
2ac5e447
JH
82'
83
a7435286
JH
84test_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
4fe10219
JK
95test_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 #
99094a7a 107 cat >expect <<-\EOF &&
4fe10219
JK
108 8e4020bb5a8d8c873b25de15933e75cc0fc275df one
109 d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index
110 9200b628cf9dc883a85a7abc8d6e6730baee589c two
111 EOF
112 echo only-in-index >only-in-index &&
b4cfcde4 113 test_when_finished "git reset --hard" &&
4fe10219
JK
114 git add only-in-index &&
115 git rev-list --objects --indexed-objects >actual &&
116 test_cmp expect actual
117'
118
b4cfcde4
JK
119test_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
f88851c6
KD
125test_expect_success '--bisect and --first-parent can not be combined' '
126 test_must_fail git rev-list --bisect --first-parent HEAD
127'
128
98985c69
JK
129test_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
19e8789b
JK
143test_expect_success 'rev-list --end-of-options' '
144 git update-ref refs/heads/--output=yikes HEAD &&
145 git rev-list --end-of-options --output=yikes >actual &&
146 test_path_is_missing yikes &&
147 git rev-list HEAD >expect &&
148 test_cmp expect actual
149'
150
a97a96fc 151test_done