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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 18, 2025 at 16:59 UTC e715f776820f22d0951e02947dd0c4f889e83df8
1 file changed +4 -4
builtin/describe.c
+4 -4
@@ -490,7 +490,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
490
491 struct process_commit_data {
492 struct object_id current_commit;
493 - struct object_id looking_for;
493 + const struct object_id *looking_for;
494 struct strbuf *dst;
495 struct rev_info *revs;
496 };
@@ -505,7 +505,7 @@ static void process_object(struct object *obj, const char *path, void *data)
505 {
506 struct process_commit_data *pcd = data;
507
508 - if (oideq(&pcd->looking_for, &obj->oid) && !pcd->dst->len) {
508 + if (oideq(pcd->looking_for, &obj->oid) && !pcd->dst->len) {
509 reset_revision_walk();
510 describe_commit(&pcd->current_commit, pcd->dst);
511 strbuf_addf(pcd->dst, ":%s", path);
@@ -514,7 +514,7 @@ static void process_object(struct object *obj, const char *path, void *data)
514 }
515 }
516
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)
518 {
519 struct rev_info revs;
520 struct strvec args = STRVEC_INIT;
@@ -554,7 +554,7 @@ static void describe(const char *arg, int last_one)
554 describe_commit(&oid, &sb);
555 else if (odb_read_object_info(the_repository->objects,
556 &oid, NULL) == OBJ_BLOB)
557 - describe_blob(oid, &sb);
557 + describe_blob(&oid, &sb);
558 else
559 die(_("%s is neither a commit nor blob"), arg);
560