path-walk: visit tags and cached objects

The rev_info that is specified for a path-walk traversal may specify visiting tag refs (both lightweight and annotated) and also may specify indexed objects (blobs and trees). Update the path-walk API to walk these objects as well. When walking tags, we need to peel the annotated objects until reaching a non-tag object. If we reach a commit, then we can add it to the pending objects to make sure we visit in the commit walk portion. If we reach a tree, then we will assume that it is a root tree. If we reach a blob, then we have no good path name and so add it to a new list of "tagged blobs". When the rev_info includes the "--indexed-objects" flag, then the pending set includes blobs and trees found in the cache entries and cache-tree. The cache entries are usually blobs, though they could be trees in the case of a sparse index. The cache-tree stores previously-hashed tree objects but these are cleared out when staging objects below those paths. We add tests that demonstrate this. The indexed objects come with a non-NULL 'path' value in the pending item. This allows us to prepopulate the 'path_to_lists' strmap with lists for these paths. The tricky thing about this walk is that we will want to combine the indexed objects walk with the commit walk, especially in the future case of walking objects during a command like 'git repack'. Whenever possible, we want the objects from the index to be grouped with similar objects in history. We don't want to miss any paths that appear only in the index and not in the commit history. Thus, we need to be careful to let the path stack be populated initially with only the root tree path (and possibly tags and tagged blobs) and go through the normal depth-first search. Afterwards, if there are other paths that are remaining in the paths_to_lists strmap, we should then iterate through the stack and visit those objects recursively. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Dec 20, 2024 at 16:21 UTC 9145660979d699733e05d7336eabb086b5266370
5 files changed +362 -27
Documentation/technical/api-path-walk.txt
+1 -1
@@ -39,7 +39,7 @@ It is also important that you do not specify the `--objects` flag for the
39 the objects will be walked in a separate way based on those starting
40 commits.
41
42 -`commits`, `blobs`, `trees`::
42 +`commits`, `blobs`, `trees`, `tags`::
43 By default, these members are enabled and signal that the path-walk
44 API should call the `path_fn` on objects of these types. Specialized
45 applications could disable some options to make it simpler to walk
path-walk.c
+181 -3
@@ -13,10 +13,13 @@
13 #include "revision.h"
14 #include "string-list.h"
15 #include "strmap.h"
16 +#include "tag.h"
17 #include "trace2.h"
18 #include "tree.h"
19 #include "tree-walk.h"
20
21 +static const char *root_path = "";
22 +
23 struct type_and_oid_list {
24 enum object_type type;
25 struct oid_array oids;
@@ -160,12 +163,16 @@ static int walk_path(struct path_walk_context *ctx,
163
164 list = strmap_get(&ctx->paths_to_lists, path);
165
166 + if (!list)
167 + BUG("provided path '%s' that had no associated list", path);
168 +
169 if (!list->oids.nr)
170 return 0;
171
172 /* Evaluate function pointer on this data, if requested. */
173 if ((list->type == OBJ_TREE && ctx->info->trees) ||
168 - (list->type == OBJ_BLOB && ctx->info->blobs))
174 + (list->type == OBJ_BLOB && ctx->info->blobs) ||
175 + (list->type == OBJ_TAG && ctx->info->tags))
176 ret = ctx->info->path_fn(path, &list->oids, list->type,
177 ctx->info->path_fn_data);
178
@@ -196,6 +203,139 @@ static void clear_paths_to_lists(struct strmap *map)
203 strmap_init(map);
204 }
205
206 +static int setup_pending_objects(struct path_walk_info *info,
207 + struct path_walk_context *ctx)
208 +{
209 + struct type_and_oid_list *tags = NULL;
210 + struct type_and_oid_list *tagged_blobs = NULL;
211 + struct type_and_oid_list *root_tree_list = NULL;
212 +
213 + if (info->tags)
214 + CALLOC_ARRAY(tags, 1);
215 + if (info->blobs)
216 + CALLOC_ARRAY(tagged_blobs, 1);
217 + if (info->trees)
218 + root_tree_list = strmap_get(&ctx->paths_to_lists, root_path);
219 +
220 + /*
221 + * Pending objects include:
222 + * * Commits at branch tips.
223 + * * Annotated tags at tag tips.
224 + * * Any kind of object at lightweight tag tips.
225 + * * Trees and blobs in the index (with an associated path).
226 + */
227 + for (size_t i = 0; i < info->revs->pending.nr; i++) {
228 + struct object_array_entry *pending = info->revs->pending.objects + i;
229 + struct object *obj = pending->item;
230 +
231 + /* Commits will be picked up by revision walk. */
232 + if (obj->type == OBJ_COMMIT)
233 + continue;
234 +
235 + /* Navigate annotated tag object chains. */
236 + while (obj->type == OBJ_TAG) {
237 + struct tag *tag = lookup_tag(info->revs->repo, &obj->oid);
238 + if (!tag) {
239 + error(_("failed to find tag %s"),
240 + oid_to_hex(&obj->oid));
241 + return -1;
242 + }
243 + if (tag->object.flags & SEEN)
244 + break;
245 + tag->object.flags |= SEEN;
246 +
247 + if (tags)
248 + oid_array_append(&tags->oids, &obj->oid);
249 + obj = tag->tagged;
250 + }
251 +
252 + if (obj->type == OBJ_TAG)
253 + continue;
254 +
255 + /* We are now at a non-tag object. */
256 + if (obj->flags & SEEN)
257 + continue;
258 + obj->flags |= SEEN;
259 +
260 + switch (obj->type) {
261 + case OBJ_TREE:
262 + if (!info->trees)
263 + continue;
264 + if (pending->path) {
265 + struct type_and_oid_list *list;
266 + char *path = *pending->path ? xstrfmt("%s/", pending->path)
267 + : xstrdup("");
268 + if (!(list = strmap_get(&ctx->paths_to_lists, path))) {
269 + CALLOC_ARRAY(list, 1);
270 + list->type = OBJ_TREE;
271 + strmap_put(&ctx->paths_to_lists, path, list);
272 + }
273 + oid_array_append(&list->oids, &obj->oid);
274 + free(path);
275 + } else {
276 + /* assume a root tree, such as a lightweight tag. */
277 + oid_array_append(&root_tree_list->oids, &obj->oid);
278 + }
279 + break;
280 +
281 + case OBJ_BLOB:
282 + if (!info->blobs)
283 + continue;
284 + if (pending->path) {
285 + struct type_and_oid_list *list;
286 + char *path = pending->path;
287 + if (!(list = strmap_get(&ctx->paths_to_lists, path))) {
288 + CALLOC_ARRAY(list, 1);
289 + list->type = OBJ_BLOB;
290 + strmap_put(&ctx->paths_to_lists, path, list);
291 + }
292 + oid_array_append(&list->oids, &obj->oid);
293 + } else {
294 + /* assume a root tree, such as a lightweight tag. */
295 + oid_array_append(&tagged_blobs->oids, &obj->oid);
296 + }
297 + break;
298 +
299 + case OBJ_COMMIT:
300 + /* Make sure it is in the object walk */
301 + if (obj != pending->item)
302 + add_pending_object(info->revs, obj, "");
303 + break;
304 +
305 + default:
306 + BUG("should not see any other type here");
307 + }
308 + }
309 +
310 + /*
311 + * Add tag objects and tagged blobs if they exist.
312 + */
313 + if (tagged_blobs) {
314 + if (tagged_blobs->oids.nr) {
315 + const char *tagged_blob_path = "/tagged-blobs";
316 + tagged_blobs->type = OBJ_BLOB;
317 + push_to_stack(ctx, tagged_blob_path);
318 + strmap_put(&ctx->paths_to_lists, tagged_blob_path, tagged_blobs);
319 + } else {
320 + oid_array_clear(&tagged_blobs->oids);
321 + free(tagged_blobs);
322 + }
323 + }
324 + if (tags) {
325 + if (tags->oids.nr) {
326 + const char *tag_path = "/tags";
327 + tags->type = OBJ_TAG;
328 + push_to_stack(ctx, tag_path);
329 + strmap_put(&ctx->paths_to_lists, tag_path, tags);
330 + } else {
331 + oid_array_clear(&tags->oids);
332 + free(tags);
333 + }
334 + }
335 +
336 + return 0;
337 +}
338 +
339 /**
340 * Given the configuration of 'info', walk the commits based on 'info->revs' and
341 * call 'info->path_fn' on each discovered path.
@@ -204,8 +344,7 @@ static void clear_paths_to_lists(struct strmap *map)
344 */
345 int walk_objects_by_path(struct path_walk_info *info)
346 {
207 - const char *root_path = "";
208 - int ret = 0;
347 + int ret;
348 size_t commits_nr = 0, paths_nr = 0;
349 struct commit *c;
350 struct type_and_oid_list *root_tree_list;
@@ -224,15 +363,34 @@ int walk_objects_by_path(struct path_walk_info *info)
363 CALLOC_ARRAY(commit_list, 1);
364 commit_list->type = OBJ_COMMIT;
365
366 + if (info->tags)
367 + info->revs->tag_objects = 1;
368 +
369 /* Insert a single list for the root tree into the paths. */
370 CALLOC_ARRAY(root_tree_list, 1);
371 root_tree_list->type = OBJ_TREE;
372 strmap_put(&ctx.paths_to_lists, root_path, root_tree_list);
373 push_to_stack(&ctx, root_path);
374
375 + /*
376 + * Set these values before preparing the walk to catch
377 + * lightweight tags pointing to non-commits and indexed objects.
378 + */
379 + info->revs->blob_objects = info->blobs;
380 + info->revs->tree_objects = info->trees;
381 +
382 if (prepare_revision_walk(info->revs))
383 die(_("failed to setup revision walk"));
384
385 + info->revs->blob_objects = info->revs->tree_objects = 0;
386 +
387 + trace2_region_enter("path-walk", "pending-walk", info->revs->repo);
388 + ret = setup_pending_objects(info, &ctx);
389 + trace2_region_leave("path-walk", "pending-walk", info->revs->repo);
390 +
391 + if (ret)
392 + return ret;
393 +
394 while ((c = get_revision(info->revs))) {
395 struct object_id *oid;
396 struct tree *t;
@@ -280,6 +438,26 @@ int walk_objects_by_path(struct path_walk_info *info)
438
439 free(path);
440 }
441 +
442 + /* Are there paths remaining? Likely they are from indexed objects. */
443 + if (!strmap_empty(&ctx.paths_to_lists)) {
444 + struct hashmap_iter iter;
445 + struct strmap_entry *entry;
446 +
447 + strmap_for_each_entry(&ctx.paths_to_lists, &iter, entry)
448 + push_to_stack(&ctx, entry->key);
449 +
450 + while (!ret && ctx.path_stack.nr) {
451 + char *path = ctx.path_stack.items[ctx.path_stack.nr - 1].string;
452 + ctx.path_stack.nr--;
453 + paths_nr++;
454 +
455 + ret = walk_path(&ctx, path);
456 +
457 + free(path);
458 + }
459 + }
460 +
461 trace2_data_intmax("path-walk", ctx.repo, "paths", paths_nr);
462 trace2_region_leave("path-walk", "path-walk", info->revs->repo);
463
path-walk.h
+2
@@ -39,12 +39,14 @@ struct path_walk_info {
39 int commits;
40 int trees;
41 int blobs;
42 + int tags;
43 };
44
45 #define PATH_WALK_INFO_INIT { \
46 .blobs = 1, \
47 .trees = 1, \
48 .commits = 1, \
49 + .tags = 1, \
50 }
51
52 void path_walk_info_init(struct path_walk_info *info);
t/helper/test-path-walk.c
+13 -2
@@ -23,6 +23,7 @@ struct path_walk_test_data {
23 uintmax_t commit_nr;
24 uintmax_t tree_nr;
25 uintmax_t blob_nr;
26 + uintmax_t tag_nr;
27 };
28
29 static int emit_block(const char *path, struct oid_array *oids,
@@ -37,11 +38,18 @@ static int emit_block(const char *path, struct oid_array *oids,
38 tdata->blob_nr += oids->nr;
39 else if (type == OBJ_COMMIT)
40 tdata->commit_nr += oids->nr;
41 + else if (type == OBJ_TAG)
42 + tdata->tag_nr += oids->nr;
43 else
44 BUG("we do not understand this type");
45
46 typestr = type_name(type);
47
48 + /* This should never be output during tests. */
49 + if (!oids->nr)
50 + printf("%"PRIuMAX":%s:%s:EMPTY\n",
51 + tdata->batch_nr, typestr, path);
52 +
53 for (size_t i = 0; i < oids->nr; i++)
54 printf("%"PRIuMAX":%s:%s:%s\n",
55 tdata->batch_nr, typestr, path,
@@ -62,6 +70,8 @@ int cmd__path_walk(int argc, const char **argv)
70 N_("toggle inclusion of blob objects")),
71 OPT_BOOL(0, "commits", &info.commits,
72 N_("toggle inclusion of commit objects")),
73 + OPT_BOOL(0, "tags", &info.tags,
74 + N_("toggle inclusion of tag objects")),
75 OPT_BOOL(0, "trees", &info.trees,
76 N_("toggle inclusion of tree objects")),
77 OPT_END(),
@@ -87,8 +97,9 @@ int cmd__path_walk(int argc, const char **argv)
97
98 printf("commits:%" PRIuMAX "\n"
99 "trees:%" PRIuMAX "\n"
90 - "blobs:%" PRIuMAX "\n",
91 - data.commit_nr, data.tree_nr, data.blob_nr);
100 + "blobs:%" PRIuMAX "\n"
101 + "tags:%" PRIuMAX "\n",
102 + data.commit_nr, data.tree_nr, data.blob_nr, data.tag_nr);
103
104 release_revisions(&revs);
105 return res;
t/t6601-path-walk.sh
+165 -21
@@ -9,29 +9,142 @@ test_description='direct path-walk API tests'
9 test_expect_success 'setup test repository' '
10 git checkout -b base &&
11
12 + # Make some objects that will only be reachable
13 + # via non-commit tags.
14 + mkdir child &&
15 + echo file >child/file &&
16 + git add child &&
17 + git commit -m "will abandon" &&
18 + git tag -a -m "tree" tree-tag HEAD^{tree} &&
19 + echo file2 >file2 &&
20 + git add file2 &&
21 + git commit --amend -m "will abandon" &&
22 + git tag tree-tag2 HEAD^{tree} &&
23 +
24 + echo blob >file &&
25 + blob_oid=$(git hash-object -t blob -w --stdin <file) &&
26 + git tag -a -m "blob" blob-tag "$blob_oid" &&
27 + echo blob2 >file2 &&
28 + blob2_oid=$(git hash-object -t blob -w --stdin <file2) &&
29 + git tag blob-tag2 "$blob2_oid" &&
30 +
31 + rm -fr child file file2 &&
32 +
33 mkdir left &&
34 mkdir right &&
35 echo a >a &&
36 echo b >left/b &&
37 echo c >right/c &&
38 git add . &&
18 - git commit -m "first" &&
39 + git commit --amend -m "first" &&
40 + git tag -m "first" first HEAD &&
41
42 echo d >right/d &&
43 git add right &&
44 git commit -m "second" &&
45 + git tag -a -m "second (under)" second.1 HEAD &&
46 + git tag -a -m "second (top)" second.2 second.1 &&
47
48 + # Set up file/dir collision in history.
49 + rm a &&
50 + mkdir a &&
51 + echo a >a/a &&
52 echo bb >left/b &&
25 - git commit -a -m "third" &&
53 + git add a left &&
54 + git commit -m "third" &&
55 + git tag -a -m "third" third &&
56
57 git checkout -b topic HEAD~1 &&
58 echo cc >right/c &&
29 - git commit -a -m "topic"
59 + git commit -a -m "topic" &&
60 + git tag -a -m "fourth" fourth
61 '
62
63 test_expect_success 'all' '
64 test-tool path-walk -- --all >out &&
65
66 + cat >expect <<-EOF &&
67 + 0:commit::$(git rev-parse topic)
68 + 0:commit::$(git rev-parse base)
69 + 0:commit::$(git rev-parse base~1)
70 + 0:commit::$(git rev-parse base~2)
71 + 1:tag:/tags:$(git rev-parse refs/tags/first)
72 + 1:tag:/tags:$(git rev-parse refs/tags/second.1)
73 + 1:tag:/tags:$(git rev-parse refs/tags/second.2)
74 + 1:tag:/tags:$(git rev-parse refs/tags/third)
75 + 1:tag:/tags:$(git rev-parse refs/tags/fourth)
76 + 1:tag:/tags:$(git rev-parse refs/tags/tree-tag)
77 + 1:tag:/tags:$(git rev-parse refs/tags/blob-tag)
78 + 2:blob:/tagged-blobs:$(git rev-parse refs/tags/blob-tag^{})
79 + 2:blob:/tagged-blobs:$(git rev-parse refs/tags/blob-tag2^{})
80 + 3:tree::$(git rev-parse topic^{tree})
81 + 3:tree::$(git rev-parse base^{tree})
82 + 3:tree::$(git rev-parse base~1^{tree})
83 + 3:tree::$(git rev-parse base~2^{tree})
84 + 3:tree::$(git rev-parse refs/tags/tree-tag^{})
85 + 3:tree::$(git rev-parse refs/tags/tree-tag2^{})
86 + 4:blob:a:$(git rev-parse base~2:a)
87 + 5:tree:right/:$(git rev-parse topic:right)
88 + 5:tree:right/:$(git rev-parse base~1:right)
89 + 5:tree:right/:$(git rev-parse base~2:right)
90 + 6:blob:right/d:$(git rev-parse base~1:right/d)
91 + 7:blob:right/c:$(git rev-parse base~2:right/c)
92 + 7:blob:right/c:$(git rev-parse topic:right/c)
93 + 8:tree:left/:$(git rev-parse base:left)
94 + 8:tree:left/:$(git rev-parse base~2:left)
95 + 9:blob:left/b:$(git rev-parse base~2:left/b)
96 + 9:blob:left/b:$(git rev-parse base:left/b)
97 + 10:tree:a/:$(git rev-parse base:a)
98 + 11:blob:file2:$(git rev-parse refs/tags/tree-tag2^{}:file2)
99 + 12:tree:child/:$(git rev-parse refs/tags/tree-tag:child)
100 + 13:blob:child/file:$(git rev-parse refs/tags/tree-tag:child/file)
101 + blobs:10
102 + commits:4
103 + tags:7
104 + trees:13
105 + EOF
106 +
107 + test_cmp_sorted expect out
108 +'
109 +
110 +test_expect_success 'indexed objects' '
111 + test_when_finished git reset --hard &&
112 +
113 + # stage change into index, adding a blob but
114 + # also invalidating the cache-tree for the root
115 + # and the "left" directory.
116 + echo bogus >left/c &&
117 + git add left &&
118 +
119 + test-tool path-walk -- --indexed-objects >out &&
120 +
121 + cat >expect <<-EOF &&
122 + 0:blob:a:$(git rev-parse HEAD:a)
123 + 1:blob:left/b:$(git rev-parse HEAD:left/b)
124 + 2:blob:left/c:$(git rev-parse :left/c)
125 + 3:blob:right/c:$(git rev-parse HEAD:right/c)
126 + 4:blob:right/d:$(git rev-parse HEAD:right/d)
127 + 5:tree:right/:$(git rev-parse topic:right)
128 + blobs:5
129 + commits:0
130 + tags:0
131 + trees:1
132 + EOF
133 +
134 + test_cmp_sorted expect out
135 +'
136 +
137 +test_expect_success 'branches and indexed objects mix well' '
138 + test_when_finished git reset --hard &&
139 +
140 + # stage change into index, adding a blob but
141 + # also invalidating the cache-tree for the root
142 + # and the "right" directory.
143 + echo fake >right/d &&
144 + git add right &&
145 +
146 + test-tool path-walk -- --indexed-objects --branches >out &&
147 +
148 cat >expect <<-EOF &&
149 0:commit::$(git rev-parse topic)
150 0:commit::$(git rev-parse base)
@@ -41,20 +154,23 @@ test_expect_success 'all' '
154 1:tree::$(git rev-parse base^{tree})
155 1:tree::$(git rev-parse base~1^{tree})
156 1:tree::$(git rev-parse base~2^{tree})
44 - 2:tree:right/:$(git rev-parse topic:right)
45 - 2:tree:right/:$(git rev-parse base~1:right)
46 - 2:tree:right/:$(git rev-parse base~2:right)
47 - 3:blob:right/d:$(git rev-parse base~1:right/d)
48 - 4:blob:right/c:$(git rev-parse base~2:right/c)
49 - 4:blob:right/c:$(git rev-parse topic:right/c)
50 - 5:tree:left/:$(git rev-parse base:left)
51 - 5:tree:left/:$(git rev-parse base~2:left)
52 - 6:blob:left/b:$(git rev-parse base~2:left/b)
53 - 6:blob:left/b:$(git rev-parse base:left/b)
54 - 7:blob:a:$(git rev-parse base~2:a)
55 - blobs:6
157 + 2:blob:a:$(git rev-parse base~2:a)
158 + 3:tree:right/:$(git rev-parse topic:right)
159 + 3:tree:right/:$(git rev-parse base~1:right)
160 + 3:tree:right/:$(git rev-parse base~2:right)
161 + 4:blob:right/d:$(git rev-parse base~1:right/d)
162 + 4:blob:right/d:$(git rev-parse :right/d)
163 + 5:blob:right/c:$(git rev-parse base~2:right/c)
164 + 5:blob:right/c:$(git rev-parse topic:right/c)
165 + 6:tree:left/:$(git rev-parse base:left)
166 + 6:tree:left/:$(git rev-parse base~2:left)
167 + 7:blob:left/b:$(git rev-parse base:left/b)
168 + 7:blob:left/b:$(git rev-parse base~2:left/b)
169 + 8:tree:a/:$(git rev-parse refs/tags/third:a)
170 + blobs:7
171 commits:4
57 - trees:9
172 + tags:0
173 + trees:10
174 EOF
175
176 test_cmp_sorted expect out
@@ -81,6 +197,7 @@ test_expect_success 'topic only' '
197 7:blob:a:$(git rev-parse base~2:a)
198 blobs:5
199 commits:3
200 + tags:0
201 trees:7
202 EOF
203
@@ -101,6 +218,7 @@ test_expect_success 'topic, not base' '
218 7:blob:a:$(git rev-parse topic:a)
219 blobs:4
220 commits:1
221 + tags:0
222 trees:3
223 EOF
224
@@ -112,13 +230,14 @@ test_expect_success 'topic, not base, only blobs' '
230 -- topic --not base >out &&
231
232 cat >expect <<-EOF &&
115 - commits:0
116 - trees:0
233 0:blob:right/d:$(git rev-parse topic:right/d)
234 1:blob:right/c:$(git rev-parse topic:right/c)
235 2:blob:left/b:$(git rev-parse topic:left/b)
236 3:blob:a:$(git rev-parse topic:a)
237 blobs:4
238 + commits:0
239 + tags:0
240 + trees:0
241 EOF
242
243 test_cmp_sorted expect out
@@ -133,8 +252,9 @@ test_expect_success 'topic, not base, only commits' '
252 cat >expect <<-EOF &&
253 0:commit::$(git rev-parse topic)
254 commits:1
136 - trees:0
255 blobs:0
256 + tags:0
257 + trees:0
258 EOF
259
260 test_cmp_sorted expect out
@@ -145,12 +265,13 @@ test_expect_success 'topic, not base, only trees' '
265 -- topic --not base >out &&
266
267 cat >expect <<-EOF &&
148 - commits:0
268 0:tree::$(git rev-parse topic^{tree})
269 1:tree:right/:$(git rev-parse topic:right)
270 2:tree:left/:$(git rev-parse topic:left)
152 - trees:3
271 + commits:0
272 blobs:0
273 + tags:0
274 + trees:3
275 EOF
276
277 test_cmp_sorted expect out
@@ -174,10 +295,33 @@ test_expect_success 'topic, not base, boundary' '
295 7:blob:a:$(git rev-parse base~1:a)
296 blobs:5
297 commits:2
298 + tags:0
299 trees:5
300 EOF
301
302 test_cmp_sorted expect out
303 '
304
305 +test_expect_success 'trees are reported exactly once' '
306 + test_when_finished "rm -rf unique-trees" &&
307 + test_create_repo unique-trees &&
308 + (
309 + cd unique-trees &&
310 + mkdir initial &&
311 + test_commit initial/file &&
312 +
313 + git switch -c move-to-top &&
314 + git mv initial/file.t ./ &&
315 + test_tick &&
316 + git commit -m moved &&
317 +
318 + git update-ref refs/heads/other HEAD
319 + ) &&
320 +
321 + test-tool -C unique-trees path-walk -- --all >out &&
322 + tree=$(git -C unique-trees rev-parse HEAD:) &&
323 + grep "$tree" out >out-filtered &&
324 + test_line_count = 1 out-filtered
325 +'
326 +
327 test_done