git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Subhaditya Nath <sn03.general@gmail.com>,
	 git@vger.kernel.org,  Patrick Steinhardt <ps@pks.im>
Subject: Re: [PATCH] t7422: remove extraneous argument to printf
Date: Wed, 09 Apr 2025 11:06:46 -0700	[thread overview]
Message-ID: <xmqqr021qkeh.fsf@gitster.g> (raw)
In-Reply-To: <CAPig+cRe9BQw=U41uOprZ5JRNgNTC46zMpyGjNy9b=y-hA8-tA@mail.gmail.com> (Eric Sunshine's message of "Wed, 9 Apr 2025 13:00:40 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Wed, Apr 9, 2025 at 12:29 PM Subhaditya Nath <sn03.general@gmail.com> wrote:
>> On Thu, Apr 3, 2025 at 10:35 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>> > [...] for the sake of consistency and to match the author's original
>> > intent, it may make more sense to retain the argument to printf and
>> > instead employ `%d`.
>>
>> The problem is, there are multiple ways the printf statement could be
>> written -
>>
>> 1) printf "[submodule \"sm-$i\"]\npath = recursive-submodule-path-$i\n"
>> 2) printf "[submodule \"sm-$i\"]\npath = recursive-submodule-path-%d\n" "$i"
>> 3) printf "[submodule \"sm-%d\"]\npath = recursive-submodule-path-$i\n" "$i"
>> 4) printf "[submodule \"sm-%d\"]\npath = recursive-submodule-path-%d\n" "$i" "$i"
>>
>> Which one of these is to be used?
>
>  The final (#4) seems most natural.

It is unfortunate that this one needs two identical things
interpolated so the overall structure with "for" loop needs to be
retained, and within the constraints, (4) is the only sensible
option, I would say.

The other one in the example in this thread could lose the for loop
by doing

   printf "160000 commit $COMMIT\trecursive-submodule-path-%d\n" \
	   $(test_seq 2000)

but for uniformity with other parts that cannot lose "for" loop, I
would not recommend going in that direction.

Thanks.

  reply	other threads:[~2025-04-09 18:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 14:48 [PATCH] t7422: remove extraneous argument to printf Subhaditya Nath
2025-04-03 17:05 ` Eric Sunshine
2025-04-09 16:19   ` Junio C Hamano
2025-04-09 16:29   ` Subhaditya Nath
2025-04-09 16:32     ` Subhaditya Nath
2025-04-09 17:00     ` Eric Sunshine
2025-04-09 18:06       ` Junio C Hamano [this message]
2025-04-09 19:11         ` [PATCH] t7422: fix extra printf argument, eliminate loops Subhaditya Nath
2025-04-09 19:11           ` Subhaditya Nath
2025-04-10 12:39             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqr021qkeh.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    --cc=sn03.general@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).