Subject: C++(C99)-style comments in git.git

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 01 Oct 2021 17:37:40 +0200

On Wed, Sep 29 2021, Carlo Marcelo Arenas Belón wrote:

> Avoid C++ style comments, that are not allowed in C89.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <[email-masked]>
> ---
>  reftable/stack_test.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/reftable/stack_test.c b/reftable/stack_test.c
> index 7a4641ab60..f907215d3c 100644
> --- a/reftable/stack_test.c
> +++ b/reftable/stack_test.c
> @@ -46,8 +46,10 @@ static int count_dir_entries(const char *dirname)
>  	return len;
>  }
>  
> -// Work linenumber into the tempdir, so we can see which tests forget to
> -// cleanup.
> +/*
> + * Work linenumber into the tempdir, so we can see which tests forget to
> + * cleanup.
> + */
>  static char *get_tmp_template(int linenumber)
>  {
>  	const char *tmp = getenv("TMPDIR");
> @@ -861,7 +863,7 @@ static void test_reftable_stack_compaction_concurrent(void)
>  
>  static void unclean_stack_close(struct reftable_stack *st)
>  {
> -	// break abstraction boundary to simulate unclean shutdown.
> +	/* break abstraction boundary to simulate unclean shutdown */
>  	int i = 0;
>  	for (; i < st->readers_len; i++) {
>  		reftable_reader_free(st->readers[i]);

This change looks fine, but FYI we had a C++ comment in git.git from
v2.21.0 with d73019feb44 (http: add support selecting http version,
2018-11-08) until now.

It'll be removed in v2.34.0 with my 2a7f64616a3 (http: correct version
check for CURL_HTTP_VERSION_2, 2021-09-13) (not the purpose of that
change).

Now, granted it's "only" compiled if you don't have NO_CURL=Y, and it's
on a "#" pre-processor line, not in the "main" code.

So it's possible (but I think not likely) that someone's cpp accepts it,
but not their cc. Or that some platform has nobody compiling with curl
(not very likely).

I'm not advocating for using "//" comments, but I think it's fair to say
given the above that they're purely an asthetic coding style preference
in the context of git.git, and not a matter of C89 portability that
anyone cares about when building or porting git.

We already have a hard dependency on a few C99-only features, I'd think
it's very unlikely that someone has say implemented designated
initializers, but not "//" comment support. So for our purposes support
for it should be universal.