diff options
| author | Justin Tobler <jltobler@gmail.com> | 2025-03-19 13:34:06 -0500 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-03-21 03:40:02 -0700 |
| commit | 1481e291129de8c9be8f85cee55071ce9dbc6e91 (patch) | |
| tree | 7aee8323efb78d9d603735735b8f6317cd7a9343 /builtin/rev-list.c | |
| parent | 87a0bdbf0f72b7561f3cd50636eee33dcb7dbcc3 (diff) | |
| download | git-1481e291129de8c9be8f85cee55071ce9dbc6e91.tar.gz | |
rev-list: inline `show_object_with_name()` in `show_object()`
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>
Diffstat (limited to 'builtin/rev-list.c')
| -rw-r--r-- | builtin/rev-list.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c index bb26bee0d4..dcd079c16c 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -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) |
