@matheusbsbs / matheus-bagliano / commits / 36d2419c9a
Fork 0

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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Feb 4, 2020 at 22:16 UTC 36d2419c9a1b38f6883318f2af9b704d5d78356f
1 file changed +3 -3
builtin/name-rev.c
+3 -3
@@ -32,7 +32,7 @@ static struct commit_rev_name rev_names;
32 /* How many generations are maximally preferred over _one_ merge traversal? */
33 #define MERGE_TRAVERSAL_WEIGHT 65535
34
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)
36 {
37 struct rev_name **slot = commit_rev_name_peek(&rev_names, commit);
38
@@ -357,11 +357,11 @@ static const char *get_exact_ref_match(const struct object *o)
357 static const char *get_rev_name(const struct object *o, struct strbuf *buf)
358 {
359 struct rev_name *n;
360 - struct commit *c;
360 + const struct commit *c;
361
362 if (o->type != OBJ_COMMIT)
363 return get_exact_ref_match(o);
364 - c = (struct commit *) o;
364 + c = (const struct commit *) o;
365 n = get_commit_rev_name(c);
366 if (!n)
367 return NULL;