revision: make get_revision_mark() return const pointer

get_revision_mark() used to return a `char *`, even though all of the
strings it was returning were string literals. Make get_revision_mark()
return a `const char *` so that callers won't be tempted to modify the
returned string.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Denton Liu 2019-11-19 16:51:13 -08:00 committed by Junio C Hamano
parent f0f9de2bd7
commit 4982516451
2 changed files with 4 additions and 4 deletions

View File

@ -3934,7 +3934,7 @@ struct commit *get_revision(struct rev_info *revs)
return c;
}
char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
{
if (commit->object.flags & BOUNDARY)
return "-";
@ -3956,7 +3956,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
{
char *mark = get_revision_mark(revs, commit);
const char *mark = get_revision_mark(revs, commit);
if (!strlen(mark))
return;
fputs(mark, stdout);

View File

@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
void reset_revision_walk(void);
int prepare_revision_walk(struct rev_info *revs);
struct commit *get_revision(struct rev_info *revs);
char *get_revision_mark(const struct rev_info *revs,
const struct commit *commit);
const char *get_revision_mark(const struct rev_info *revs,
const struct commit *commit);
void put_revision_mark(const struct rev_info *revs,
const struct commit *commit);