[RFC,v2,13/13] walken: reverse the object walk order
diff mbox series

Message ID 20190626235032.177551-14-emilyshaffer@google.com
State New
Headers show
  • example implementation of revwalk tutorial
Related show

Commit Message

Emily Shaffer June 26, 2019, 11:50 p.m. UTC
Demonstrate that just like commit walks, object walks can have their
order reversed. Additionally, add verbose logging of objects encountered
in order to let contributors prove to themselves that the walk has
actually been reversed. With this commit, `git walken` becomes extremely
chatty - it's recommended to pipe the output through `head` or `tail` or
to redirect it into a file.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Change-Id: I91883b209a61ae4d87855878291e487fe36220c4
 builtin/walken.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox series

diff --git a/builtin/walken.c b/builtin/walken.c
index dc59ff5009..37b02887a5 100644
--- a/builtin/walken.c
+++ b/builtin/walken.c
@@ -112,11 +112,13 @@  static int git_walken_config(const char *var, const char *value, void *cb)
 static void walken_show_commit(struct commit *cmt, void *buf)
+	printf("commit: %s\n", oid_to_hex(&cmt->object.oid));
 static void walken_show_object(struct object *obj, const char *str, void *buf)
+	printf("%s: %s\n", type_name(obj->type), oid_to_hex(&obj->oid));
 	switch (obj->type) {
 	case OBJ_TREE:
@@ -158,6 +160,7 @@  static void walken_object_walk(struct rev_info *rev)
 	rev->tag_objects = 1;
 	rev->tree_blobs_in_commit_order = 1;
 	rev->exclude_promisor_objects = 1;
+	rev->reverse = 1;
 	if (prepare_revision_walk(rev))
 		die(_("revision walk setup failed"));