All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2 3/2] diff-no-index: simplify argv index calculation
Date: Wed, 07 Sep 2022 12:37:08 -0700	[thread overview]
Message-ID: <xmqqr10nt1qz.fsf@gitster.g> (raw)
In-Reply-To: <9ea33608-3a6c-c0ef-9bb3-4bb535009aeb@web.de> ("René Scharfe"'s message of "Wed, 7 Sep 2022 13:45:42 +0200")

René Scharfe <l.s.r@web.de> writes:

> Since 16bb3d714d (diff --no-index: use parse_options() instead of
> diff_opt_parse(), 2019-03-24) argc must be 2 if we reach the loop, i.e.
> argc - 2 == 0.  Remove that inconsequential term.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> Bonus patch "while at it", would have saved me from going "huh?".
> Generated using -U8 for easier review.

All three patches made sense to me.  Thanks.

>
>  diff-no-index.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/diff-no-index.c b/diff-no-index.c
> index a18f6c3c63..18edbdf4b5 100644
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -262,17 +262,17 @@ int diff_no_index(struct rev_info *revs,
>  	if (argc != 2) {
>  		if (implicit_no_index)
>  			warning(_("Not a git repository. Use --no-index to "
>  				  "compare two paths outside a working tree"));
>  		usage_with_options(diff_no_index_usage, options);
>  	}
>  	FREE_AND_NULL(options);
>  	for (i = 0; i < 2; i++) {
> -		const char *p = argv[argc - 2 + i];
> +		const char *p = argv[i];
>  		if (!strcmp(p, "-"))
>  			/*
>  			 * stdin should be spelled as "-"; if you have
>  			 * path that is "-", spell it as "./-".
>  			 */
>  			p = file_from_standard_input;
>  		else if (prefix)
>  			p = to_free[i] = prefix_filename(prefix, p);
> --
> 2.37.2

  reply	other threads:[~2022-09-07 19:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 21:27 [PATCH] unleak paths allocated in "diff --no-index" Junio C Hamano
2022-09-02 23:49 ` [PATCH v2] diff --no-index: unleak paths[] elements Junio C Hamano
2022-09-03  6:00   ` René Scharfe
2022-09-05 20:26     ` Junio C Hamano
2022-09-06 12:31       ` [PATCH 1/2] diff-no-index: release strbuf on queue error René Scharfe
2022-09-07  6:01         ` René Scharfe
2022-09-06 12:31       ` [PATCH 2/2] diff-no-index: release prefixed filenames René Scharfe
2022-09-07 10:03         ` Johannes Schindelin
2022-09-07 11:19           ` René Scharfe
2022-09-07 11:36       ` [PATCH v2 1/2] diff-no-index: release strbuf on queue error René Scharfe
2022-09-07 11:37       ` [PATCH v2 2/2] diff-no-index: release prefixed filenames René Scharfe
2022-09-07 11:45       ` [PATCH v2 3/2] diff-no-index: simplify argv index calculation René Scharfe
2022-09-07 19:37         ` Junio C Hamano [this message]
2022-09-05 10:03   ` [PATCH v2] diff --no-index: unleak paths[] elements Johannes Schindelin
2022-09-05 11:01     ` Ævar Arnfjörð Bjarmason
2022-09-07 10:06       ` Johannes Schindelin
2022-09-07 12:31         ` Ævar Arnfjörð Bjarmason

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=xmqqr10nt1qz.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=l.s.r@web.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.