Skip to content

Commit 1481e29

Browse files
jltoblergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87a0bdb commit 1481e29

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

builtin/rev-list.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,15 @@ static void show_object(struct object *obj, const char *name, void *cb_data)
357357
return;
358358
}
359359

360-
if (arg_show_object_names)
361-
show_object_with_name(stdout, obj, name);
362-
else
363-
printf("%s\n", oid_to_hex(&obj->oid));
360+
printf("%s", oid_to_hex(&obj->oid));
361+
362+
if (arg_show_object_names) {
363+
putchar(' ');
364+
for (const char *p = name; *p && *p != '\n'; p++)
365+
putchar(*p);
366+
}
367+
368+
putchar('\n');
364369
}
365370

366371
static void show_edge(struct commit *commit)

revision.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ implement_shared_commit_slab(revision_sources, char *);
5959

6060
static inline int want_ancestry(const struct rev_info *revs);
6161

62-
void show_object_with_name(FILE *out, struct object *obj, const char *name)
63-
{
64-
fprintf(out, "%s ", oid_to_hex(&obj->oid));
65-
for (const char *p = name; *p && *p != '\n'; p++)
66-
fputc(*p, out);
67-
fputc('\n', out);
68-
}
69-
7062
static void mark_blob_uninteresting(struct blob *blob)
7163
{
7264
if (!blob)

revision.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,6 @@ void mark_parents_uninteresting(struct rev_info *revs, struct commit *commit);
489489
void mark_tree_uninteresting(struct repository *r, struct tree *tree);
490490
void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees);
491491

492-
void show_object_with_name(FILE *, struct object *, const char *);
493-
494492
/**
495493
* Helpers to check if a reference should be excluded.
496494
*/

0 commit comments

Comments
 (0)