Skip to content

Commit 36d2419

Browse files
rscharfegitster
authored andcommitted
name-rev: respect const qualifier
Keep the const qualifier of the first parameter of get_rev_name() even when casting the object pointer to a commit pointer, and further for the parameter of get_commit_rev_name(), as all these uses are read-only. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71620ca commit 36d2419

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/name-rev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static struct commit_rev_name rev_names;
3232
/* How many generations are maximally preferred over _one_ merge traversal? */
3333
#define MERGE_TRAVERSAL_WEIGHT 65535
3434

35-
static struct rev_name *get_commit_rev_name(struct commit *commit)
35+
static struct rev_name *get_commit_rev_name(const struct commit *commit)
3636
{
3737
struct rev_name **slot = commit_rev_name_peek(&rev_names, commit);
3838

@@ -357,11 +357,11 @@ static const char *get_exact_ref_match(const struct object *o)
357357
static const char *get_rev_name(const struct object *o, struct strbuf *buf)
358358
{
359359
struct rev_name *n;
360-
struct commit *c;
360+
const struct commit *c;
361361

362362
if (o->type != OBJ_COMMIT)
363363
return get_exact_ref_match(o);
364-
c = (struct commit *) o;
364+
c = (const struct commit *) o;
365365
n = get_commit_rev_name(c);
366366
if (!n)
367367
return NULL;

0 commit comments

Comments
 (0)