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

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

Commit Message

Emily Shaffer June 7, 2019, 1:08 a.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>
 builtin/walken.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox series

diff --git a/builtin/walken.c b/builtin/walken.c
index d93725ee88..4bfee3a2d7 100644
--- a/builtin/walken.c
+++ b/builtin/walken.c
@@ -102,11 +102,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:
@@ -149,6 +151,7 @@  static int 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"));