Merge branch 'jc/relnotes-v0-extension-update' into master
[git/raj.git] / t / t6000-rev-list-misc.sh
blob3dc1ad8f719926140ce31a9528c8f870977484b1
1 #!/bin/sh
3 test_description='miscellaneous rev-list tests'
5 . ./test-lib.sh
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
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
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 &&
26 git rev-list --objects HEAD -- foo >output &&
27 grep foo/file output &&
29 git rev-list --objects HEAD -- foo/file >output &&
30 grep foo/file output &&
31 ! grep unwanted_file output
34 test_expect_success 'rev-list --objects with pathspecs and copied files' '
35 git checkout --orphan junio-testcase &&
36 git rm -rf . &&
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 &&
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
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
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
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
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
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
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
95 test_expect_success 'rev-list can show index objects' '
96 # Of the blobs and trees in the index, note:
98 # - we do not show two/three, because it is the
99 # same blob as "one", and we show objects only once
101 # - we do show the tree "two", because it has a valid cache tree
102 # from the last commit
104 # - we do not show the root tree; since we updated the index, it
105 # does not have a valid cache tree
107 echo only-in-index >only-in-index &&
108 test_when_finished "git reset --hard" &&
109 rev1=$(git rev-parse HEAD:one) &&
110 rev2=$(git rev-parse HEAD:two) &&
111 revi=$(git hash-object only-in-index) &&
112 cat >expect <<-EOF &&
113 $rev1 one
114 $revi only-in-index
115 $rev2 two
117 git add only-in-index &&
118 git rev-list --objects --indexed-objects >actual &&
119 test_cmp expect actual
122 test_expect_success 'rev-list can negate index objects' '
123 git rev-parse HEAD >expect &&
124 git rev-list -1 --objects HEAD --not --indexed-objects >actual &&
125 test_cmp expect actual
128 test_expect_success '--bisect and --first-parent can not be combined' '
129 test_must_fail git rev-list --bisect --first-parent HEAD
132 test_expect_success '--header shows a NUL after each commit' '
133 # We know that there is no Q in the true payload; names and
134 # addresses of the authors and the committers do not have
135 # any, and object names or header names do not, either.
136 git rev-list --header --max-count=2 HEAD |
137 nul_to_q |
138 grep "^Q" >actual &&
139 cat >expect <<-EOF &&
140 Q$(git rev-parse HEAD~1)
143 test_cmp expect actual
146 test_expect_success 'rev-list --end-of-options' '
147 git update-ref refs/heads/--output=yikes HEAD &&
148 git rev-list --end-of-options --output=yikes >actual &&
149 test_path_is_missing yikes &&
150 git rev-list HEAD >expect &&
151 test_cmp expect actual
154 test_expect_success 'rev-list --count' '
155 count=$(git rev-list --count HEAD) &&
156 git rev-list HEAD >actual &&
157 test_line_count = $count actual
160 test_expect_success 'rev-list --count --objects' '
161 count=$(git rev-list --count --objects HEAD) &&
162 git rev-list --objects HEAD >actual &&
163 test_line_count = $count actual
166 test_done