Subject: Re: [PATCH 3/5] CodingGuidelines: allow declaring variables in for loops

From: Junio C Hamano <[email-masked]>
Date: Fri, 07 Oct 2022 11:12:40 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> diff --git a/revision.c b/revision.c
> index 36e31942cee..8f2623b3b5a 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -47,13 +47,6 @@ static inline int want_ancestry(const struct rev_info *revs);
>  void show_object_with_name(FILE *out, struct object *obj, const char *name)
>  {
>  	fprintf(out, "%s ", oid_to_hex(&obj->oid));
> -	/*
> -	 * 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 [email-masked]. 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);

Good.  Thanks for not forgetting to remove this.

> diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
> index 506835521a4..f8a62d892d9 100644
> --- a/t/helper/test-parse-options.c
> +++ b/t/helper/test-parse-options.c
> @@ -195,8 +195,7 @@ int cmd__parse_options(int argc, const char **argv)
>  
>  static void print_args(int argc, const char **argv)
>  {
> -	int i;
> -	for (i = 0; i < argc; i++)
> +	for (int i = 0; i < argc; i++)
>  		printf("arg %02d: %s\n", i, argv[i]);
>  }

This does not belong to this patch.  If the current code as written
is acceptable, it is not worth patch churn to rewrite it.