diff mbox series

[03/10] name-rev: respect const qualifier

Message ID 9993ab3c-41c0-cf0a-fc55-72853a54a49f@web.de (mailing list archive)
State New, archived
Headers show
Series name-rev: improve memory usage | expand

Commit Message

René Scharfe Feb. 4, 2020, 9:16 p.m. UTC
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>
 builtin/name-rev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff mbox series


diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index a8de9cc561..2e6820bd5b 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -32,7 +32,7 @@  static struct commit_rev_name rev_names;
 /* How many generations are maximally preferred over _one_ merge traversal? */

-static struct rev_name *get_commit_rev_name(struct commit *commit)
+static struct rev_name *get_commit_rev_name(const struct commit *commit)
 	struct rev_name **slot = commit_rev_name_peek(&rev_names, commit);

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

 	if (o->type != OBJ_COMMIT)
 		return get_exact_ref_match(o);
-	c = (struct commit *) o;
+	c = (const struct commit *) o;
 	n = get_commit_rev_name(c);
 	if (!n)
 		return NULL;