Skip to content

Commit e715f77

Browse files
peffgitster
authored andcommitted
describe: pass oid struct by const pointer
We pass a "struct object_id" to describe_blob() by value. This isn't wrong, as an oid is composed only of copy-able values. But it's unusual; typically we pass structs by const pointer, including object_ids. Let's do so. It similarly makes sense for us to hold that pointer in the callback data (rather than yet another copy of the oid). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c44beea commit e715f77

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/describe.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
490490

491491
struct process_commit_data {
492492
struct object_id current_commit;
493-
struct object_id looking_for;
493+
const struct object_id *looking_for;
494494
struct strbuf *dst;
495495
struct rev_info *revs;
496496
};
@@ -505,7 +505,7 @@ static void process_object(struct object *obj, const char *path, void *data)
505505
{
506506
struct process_commit_data *pcd = data;
507507

508-
if (oideq(&pcd->looking_for, &obj->oid) && !pcd->dst->len) {
508+
if (oideq(pcd->looking_for, &obj->oid) && !pcd->dst->len) {
509509
reset_revision_walk();
510510
describe_commit(&pcd->current_commit, pcd->dst);
511511
strbuf_addf(pcd->dst, ":%s", path);
@@ -514,7 +514,7 @@ static void process_object(struct object *obj, const char *path, void *data)
514514
}
515515
}
516516

517-
static void describe_blob(struct object_id oid, struct strbuf *dst)
517+
static void describe_blob(const struct object_id *oid, struct strbuf *dst)
518518
{
519519
struct rev_info revs;
520520
struct strvec args = STRVEC_INIT;
@@ -554,7 +554,7 @@ static void describe(const char *arg, int last_one)
554554
describe_commit(&oid, &sb);
555555
else if (odb_read_object_info(the_repository->objects,
556556
&oid, NULL) == OBJ_BLOB)
557-
describe_blob(oid, &sb);
557+
describe_blob(&oid, &sb);
558558
else
559559
die(_("%s is neither a commit nor blob"), arg);
560560

0 commit comments

Comments
 (0)