This helps construct tree dictionary in pack v4.
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
---
builtin/pack-objects.c | 2 +-
builtin/rev-list.c | 4 ++--
list-objects.c | 9 ++++++++-
list-objects.h | 3 ++-
upload-pack.c | 2 +-
5 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index ef68fc5..b38d3dc 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2380,7 +2380,7 @@ static void get_object_list(int ac, const char **av)
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
mark_edges_uninteresting(revs.commits, &revs, show_edge);
- traverse_commit_list(&revs, show_commit, show_object, NULL);
+ traverse_commit_list(&revs, show_commit, NULL, show_object, NULL);
if (keep_unreachable)
add_objects_in_unpacked_packs(&revs);
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index a5ec30d..b25f896 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -243,7 +243,7 @@ static int show_bisect_vars(struct rev_list_info *info, int
reaches, int all)
strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
if (flags & BISECT_SHOW_ALL) {
- traverse_commit_list(revs, show_commit, show_object, info);
+ traverse_commit_list(revs, show_commit, NULL, show_object,
info);
printf("------\n");
}
@@ -348,7 +348,7 @@ int cmd_rev_list(int argc, const char **argv, const char
*prefix)
return show_bisect_vars(&info, reaches, all);
}
- traverse_commit_list(&revs, show_commit, show_object, &info);
+ traverse_commit_list(&revs, show_commit, NULL, show_object, &info);
if (revs.count) {
if (revs.left_right && revs.cherry_mark)
diff --git a/list-objects.c b/list-objects.c
index 3dd4a96..6def897 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -61,6 +61,7 @@ static void process_gitlink(struct rev_info *revs,
static void process_tree(struct rev_info *revs,
struct tree *tree,
+ show_tree_entry_fn show_tree_entry,
show_object_fn show,
struct name_path *path,
struct strbuf *base,
@@ -107,9 +108,13 @@ static void process_tree(struct rev_info *revs,
continue;
}
+ if (show_tree_entry)
+ show_tree_entry(&entry, cb_data);
+
if (S_ISDIR(entry.mode))
process_tree(revs,
lookup_tree(entry.sha1),
+ show_tree_entry,
show, &me, base, entry.path,
cb_data);
else if (S_ISGITLINK(entry.mode))
@@ -167,6 +172,7 @@ static void add_pending_tree(struct rev_info *revs, struct
tree *tree)
void traverse_commit_list(struct rev_info *revs,
show_commit_fn show_commit,
+ show_tree_entry_fn show_tree_entry,
show_object_fn show_object,
void *data)
{
@@ -196,7 +202,8 @@ void traverse_commit_list(struct rev_info *revs,
continue;
}
if (obj->type == OBJ_TREE) {
- process_tree(revs, (struct tree *)obj, show_object,
+ process_tree(revs, (struct tree *)obj,
+ show_tree_entry, show_object,
NULL, &base, name, data);
continue;
}
diff --git a/list-objects.h b/list-objects.h
index 3db7bb6..297b2e0 100644
--- a/list-objects.h
+++ b/list-objects.h
@@ -2,8 +2,9 @@
#define LIST_OBJECTS_H
typedef void (*show_commit_fn)(struct commit *, void *);
+typedef void (*show_tree_entry_fn)(const struct name_entry *, void *);
typedef void (*show_object_fn)(struct object *, const struct name_path *,
const char *, void *);
-void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn,
void *);
+void traverse_commit_list(struct rev_info *, show_commit_fn,
show_tree_entry_fn, show_object_fn, void *);
typedef void (*show_edge_fn)(struct commit *);
void mark_edges_uninteresting(struct commit_list *, struct rev_info *,
show_edge_fn);
diff --git a/upload-pack.c b/upload-pack.c
index 127e59a..ccf76d9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -125,7 +125,7 @@ static int do_rev_list(int in, int out, void *user_data)
for (i = 0; i < extra_edge_obj.nr; i++)
fprintf(pack_pipe, "-%s\n", sha1_to_hex(
extra_edge_obj.objects[i].item->sha1));
- traverse_commit_list(&revs, show_commit, show_object, NULL);
+ traverse_commit_list(&revs, show_commit, NULL, show_object, NULL);
fflush(pack_pipe);
fclose(pack_pipe);
return 0;
--
1.8.2.83.gc99314b
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html