diff mbox series

[2/7] list-objects: move tag processing into its own function

Message ID 9feadba12420842437047fe6ea1351a8a330714a.1614600555.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series rev-parse: implement object type filter | expand

Commit Message

Patrick Steinhardt March 1, 2021, 12:20 p.m. UTC
Move processing of tags into its own function to make the logic easier
to extend when we're going to implement filtering for tags. No change in
behaviour is expected from this commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 list-objects.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/list-objects.c b/list-objects.c
index e19589baa0..093adf85b1 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -213,6 +213,15 @@  static void process_tree(struct traversal_context *ctx,
 	free_tree_buffer(tree);
 }
 
+static void process_tag(struct traversal_context *ctx,
+			struct tag *tag,
+			struct strbuf *base,
+			const char *name)
+{
+	tag->object.flags |= SEEN;
+	ctx->show_object(&tag->object, name, ctx->show_data);
+}
+
 static void mark_edge_parents_uninteresting(struct commit *commit,
 					    struct rev_info *revs,
 					    show_edge_fn show_edge)
@@ -334,8 +343,7 @@  static void traverse_trees_and_blobs(struct traversal_context *ctx,
 		if (obj->flags & (UNINTERESTING | SEEN))
 			continue;
 		if (obj->type == OBJ_TAG) {
-			obj->flags |= SEEN;
-			ctx->show_object(obj, name, ctx->show_data);
+			process_tag(ctx, (struct tag *)obj, base, name);
 			continue;
 		}
 		if (!path)