summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-21 23:03:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-21 23:03:15 (GMT)
commit5a4069a1d86d98e3ba3f6aa748b5ad323983c420 (patch)
tree925e77e33b158fd922810e8cdc28ac963457030b /revision.c
parenta0f5ca94dd27fb3636bddde251ce3db0a18fc49e (diff)
parent44ba10d6712268d6a76557b054b0d16b75c9501f (diff)
downloadgit-5a4069a1d86d98e3ba3f6aa748b5ad323983c420.zip
git-5a4069a1d86d98e3ba3f6aa748b5ad323983c420.tar.gz
git-5a4069a1d86d98e3ba3f6aa748b5ad323983c420.tar.bz2
Merge branch 'jc/c99-var-decl-in-for-loop'
Weather balloon to find compilers that do not grok variable declaration in the for() loop. * jc/c99-var-decl-in-for-loop: revision: use C99 declaration of variable in for() loop
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/revision.c b/revision.c
index 1981a08..5390a47 100644
--- a/revision.c
+++ b/revision.c
@@ -44,10 +44,15 @@ static inline int want_ancestry(const struct rev_info *revs);
void show_object_with_name(FILE *out, struct object *obj, const char *name)
{
- const char *p;
-
fprintf(out, "%s ", oid_to_hex(&obj->oid));
- for (p = name; *p && *p != '\n'; p++)
+ /*
+ * This "for (const char *p = ..." is made as a first step towards
+ * making use of such declarations elsewhere in our codebase. If
+ * it causes compilation problems on your platform, please report
+ * it to the Git mailing list at git@vger.kernel.org. In the meantime,
+ * adding -std=gnu99 to CFLAGS may help if you are with older GCC.
+ */
+ for (const char *p = name; *p && *p != '\n'; p++)
fputc(*p, out);
fputc('\n', out);
}