]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rev-list: inline `show_object_with_name()` in `show_object()`
authorJustin Tobler <jltobler@gmail.com>
Wed, 19 Mar 2025 18:34:06 +0000 (13:34 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2025 10:40:02 +0000 (03:40 -0700)
The `show_object_with_name()` function only has a single call site.
Inline call to `show_object_with_name()` in `show_object()` so the
explicit function can be cleaned up and live closer to where it is used.
While at it, factor out the code that prints the OID and newline for
both objects with and without a name. In a subsequent commit,
`show_object()` is modified to support printing object information in a
NUL-delimited format.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-list.c
revision.c
revision.h

index bb26bee0d4565ad2c9df92fe7035bf8dd556217c..dcd079c16cc8131a4f0717ec32d8b4cbe1517a21 100644 (file)
@@ -357,10 +357,15 @@ static void show_object(struct object *obj, const char *name, void *cb_data)
                return;
        }
 
-       if (arg_show_object_names)
-               show_object_with_name(stdout, obj, name);
-       else
-               printf("%s\n", oid_to_hex(&obj->oid));
+       printf("%s", oid_to_hex(&obj->oid));
+
+       if (arg_show_object_names) {
+               putchar(' ');
+               for (const char *p = name; *p && *p != '\n'; p++)
+                       putchar(*p);
+       }
+
+       putchar('\n');
 }
 
 static void show_edge(struct commit *commit)
index c4390f0938cbdeb3a08a310cf2ca5aaed944d377..0eaebe447815615d5bfdae5316199566468a5c2e 100644 (file)
@@ -59,14 +59,6 @@ implement_shared_commit_slab(revision_sources, char *);
 
 static inline int want_ancestry(const struct rev_info *revs);
 
-void show_object_with_name(FILE *out, struct object *obj, const char *name)
-{
-       fprintf(out, "%s ", oid_to_hex(&obj->oid));
-       for (const char *p = name; *p && *p != '\n'; p++)
-               fputc(*p, out);
-       fputc('\n', out);
-}
-
 static void mark_blob_uninteresting(struct blob *blob)
 {
        if (!blob)
index 71e984c452b8d7e929cf93c843b70ff219445d9d..21c6a698995efd8c50ec6dbb4c284f9c54a50115 100644 (file)
@@ -489,8 +489,6 @@ void mark_parents_uninteresting(struct rev_info *revs, struct commit *commit);
 void mark_tree_uninteresting(struct repository *r, struct tree *tree);
 void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees);
 
-void show_object_with_name(FILE *, struct object *, const char *);
-
 /**
  * Helpers to check if a reference should be excluded.
  */