-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WORK-IN-PROGRESS] Introduce the path walk API into Git for Windows #5146
Changes from 1 commit
6354d7a
c8e08c3
b05a276
e02f7b3
4236e4f
31c9b45
356abc9
3a421ff
b9471b6
c4b3490
ca37a49
0a20a17
91c4d57
53632be
c63928e
3e9b671
af7d53f
d192ae7
5f7e131
ab0bc08
bd8b5b5
c6d4832
c2092f0
bbc57f7
32fca07
c145b9e
72191a0
5039f03
e43582c
88fee5b
d17e503
d7e7283
98a5786
9d0690a
556335a
69aa8d8
5001883
3ab1bda
84c8a06
16cd9a3
c8f1239
b5c2265
fee8f88
489ce0c
9b78d40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
#include "revision.h" | ||
#include "string-list.h" | ||
#include "strmap.h" | ||
#include "tag.h" | ||
#include "trace2.h" | ||
#include "tree.h" | ||
#include "tree-walk.h" | ||
|
@@ -215,6 +216,9 @@ int walk_objects_by_path(struct path_walk_info *info) | |
.paths_to_lists = STRMAP_INIT | ||
}; | ||
|
||
struct oid_array tagged_tree_list = OID_ARRAY_INIT; | ||
struct oid_array tagged_blob_list = OID_ARRAY_INIT; | ||
|
||
trace2_region_enter("path-walk", "commit-walk", info->revs->repo); | ||
|
||
CALLOC_ARRAY(commit_list, 1); | ||
|
@@ -260,6 +264,60 @@ int walk_objects_by_path(struct path_walk_info *info) | |
oid_array_clear(&commit_list->oids); | ||
free(commit_list); | ||
|
||
if (info->tags) { | ||
struct oid_array tags = OID_ARRAY_INIT; | ||
|
||
trace2_region_enter("path-walk", "tag-walk", info->revs->repo); | ||
|
||
/* | ||
* Walk any pending objects at this point, but they should only | ||
* be tags. | ||
*/ | ||
for (size_t i = 0; i < info->revs->pending.nr; i++) { | ||
struct object_array_entry *pending = info->revs->pending.objects + i; | ||
struct object *obj = pending->item; | ||
|
||
while (obj->type == OBJ_TAG) { | ||
struct tag *tag = lookup_tag(info->revs->repo, | ||
&obj->oid); | ||
oid_array_append(&tags, &obj->oid); | ||
obj = tag->tagged; | ||
} | ||
|
||
switch (obj->type) { | ||
case OBJ_TREE: | ||
oid_array_append(&tagged_tree_list, &obj->oid); | ||
break; | ||
|
||
case OBJ_BLOB: | ||
oid_array_append(&tagged_blob_list, &obj->oid); | ||
break; | ||
|
||
case OBJ_COMMIT: | ||
/* skip */ | ||
break; | ||
|
||
default: | ||
BUG("should not see any other type here"); | ||
} | ||
} | ||
|
||
info->path_fn("initial", &tags, OBJ_TAG, info->path_fn_data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably say And maybe even The same goes for Also, do we want to prevent the function from being called with zero tags in case the caller asked for tags to be included but there were none to be found? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that means that you have to look at the object type first in the callback, and only interpret the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, we want the path to matter for trees, too. When considering deltas in the |
||
|
||
if (tagged_tree_list.nr) | ||
info->path_fn("tagged-trees", &tagged_tree_list, OBJ_TREE, | ||
info->path_fn_data); | ||
if (tagged_blob_list.nr) | ||
info->path_fn("tagged-blobs", &tagged_blob_list, OBJ_BLOB, | ||
info->path_fn_data); | ||
|
||
trace2_data_intmax("path-walk", ctx.repo, "tags", tags.nr); | ||
trace2_region_leave("path-walk", "tag-walk", info->revs->repo); | ||
oid_array_clear(&tags); | ||
oid_array_clear(&tagged_tree_list); | ||
oid_array_clear(&tagged_blob_list); | ||
} | ||
|
||
string_list_append(&ctx.path_stack, root_path); | ||
|
||
trace2_region_enter("path-walk", "path-walk", info->revs->repo); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear that we have to handle tags in
revs->pending
first, accumulating the list before walking the commits, but then only processing them afterward (to avoid double-accounting for blobs that are both tagged directly and that are reachable via a tree).I've just added a test helper in 489ce0c and used the left-over of
t8100-*.sh -d
:As you can see, there is a tag object
four
but it is not reported because the revision walk removes it from thepending
list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag stuff is the weakest part of the path-walk API and demonstrates the need for a
git rev-list
-like test helper that checks which objects are collected for each path and object type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the test helper I implemented is a good start?