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 &&
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' '
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 &&
41 git add one two/three &&
45 ONE=$(git rev-parse HEAD:one) &&
46 git rev-list --objects HEAD two >output &&
47 grep "$ONE two/three" 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 &&
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 &&
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 cat >expect <<-\EOF &&
108 8e4020bb5a8d8c873b25de15933e75cc0fc275df one
109 d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index
110 9200b628cf9dc883a85a7abc8d6e6730baee589c two
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
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
125 test_expect_success '--bisect and --first-parent can not be combined' '
126 test_must_fail git rev-list --bisect --first-parent HEAD
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 |
136 cat >expect <<-EOF &&
137 Q$(git rev-parse HEAD~1)
140 test_cmp expect actual
143 test_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