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>
Denton Liu committed
Nov 19, 2019 at 16:51 UTC
4982516451ed4979bc7fc1a7f002fc310b060118
2 files changed
+4
-4
revision.c
+2
-2
@@ -3934,7 +3934,7 @@ struct commit *get_revision(struct rev_info *revs)
3934
return c;
3935
}
3936
3937
-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
3937
+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
3938
{
3939
if (commit->object.flags & BOUNDARY)
3940
return "-";
@@ -3956,7 +3956,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
3956
3957
void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
3958
{
3959
- char *mark = get_revision_mark(revs, commit);
3959
+ const char *mark = get_revision_mark(revs, commit);
3960
if (!strlen(mark))
3961
return;
3962
fputs(mark, stdout);
revision.h
+2
-2
@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
322
void reset_revision_walk(void);
323
int prepare_revision_walk(struct rev_info *revs);
324
struct commit *get_revision(struct rev_info *revs);
325
-char *get_revision_mark(const struct rev_info *revs,
326
- const struct commit *commit);
325
+const char *get_revision_mark(const struct rev_info *revs,
326
+ const struct commit *commit);
327
void put_revision_mark(const struct rev_info *revs,
328
const struct commit *commit);
329