3 test_description='miscellaneous rev-list tests'
7 test_expect_success setup '
8 echo content1 >wanted_file &&
9 echo content2 >unwanted_file &&
10 git add wanted_file unwanted_file &&
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
21 test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
28 git rev-list --objects HEAD -- foo >output &&
29 grep foo/file output &&
31 git rev-list --objects HEAD -- foo/file >output &&
32 grep foo/file output &&
33 ! grep unwanted_file output
36 test_expect_success 'rev-list --objects with pathspecs and copied files' '
37 git checkout --orphan junio-testcase &&
43 git add one two/three &&
47 ONE=$(git rev-parse HEAD:one) &&
48 git rev-list --objects HEAD two >output &&
49 grep "$ONE two/three" output &&
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 &&
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
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
73 test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
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
82 test_expect_success 'propagate uninteresting flag down correctly' '
83 git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual &&
84 test_must_be_empty actual
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 &&
95 test_cmp expect actual
98 test_expect_success 'rev-list can show index objects' '
99 # Of the blobs and trees in the index, note:
101 # - we do not show two/three, because it is the
102 # same blob as "one", and we show objects only once
104 # - we do show the tree "two", because it has a valid cache tree
105 # from the last commit
107 # - we do not show the root tree; since we updated the index, it
108 # does not have a valid cache tree
110 echo only-in-index >only-in-index &&
111 test_when_finished "git reset --hard" &&
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 &&
120 git add only-in-index &&
121 git rev-list --objects --indexed-objects >actual &&
122 test_cmp expect actual
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
131 test_expect_success '--bisect and --first-parent can not be combined' '
132 test_must_fail git rev-list --bisect --first-parent HEAD
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 |
142 cat >expect <<-EOF &&
143 Q$(git rev-parse HEAD~1)
146 test_cmp expect actual
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
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
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