git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: Git Users <git@vger.kernel.org>
Subject: Re: git format-patch --range-diff accepts non-quoted arguments (shouldn't it be?)
Date: Fri, 08 Oct 2021 11:10:35 -0700	[thread overview]
Message-ID: <xmqq7denl750.fsf@gitster.g> (raw)
In-Reply-To: <c2c5f3b0-dfdb-0f3f-4c64-8f44d3e74a07@gmail.com> (Bagas Sanjaya's message of "Fri, 8 Oct 2021 16:34:15 +0700")

Bagas Sanjaya <bagasdotme@gmail.com> writes:

> I think it is rather odd that `git format-patch --range-diff` accepts
> <previous> argument without enclosed in quotes, since it is always 
> multi-word (separated by space). E.g., below works:

What do you mean by "it" in "since it is always"?  If you meant
"<previous>", your may want to re-read "git format-patch --help".

The <previous> will most likely not be a multi-word argument
separated by a space.  It is a way to specify the "previous range",
i.e. one of the two ranges given to the range-diff command to be
compared.  The other range is what the user gave the command to
specify what patches to work on for the latest iteration.

So...

>     $ git format-patch <options> --range-diff=main..previous main..HEAD

This works of course, because <previous> is main..previous (without
any SP anywhere, and needs no quoting), main..HEAD is the range to
take patches from *and* also given to range-diff as the current
range.

> but below returns nothing:
>
>     $ git format-patch <options> --range-diff="main..previous main..HEAD"

This gives an empty range to work on to the command.  The range-diff
argument seems strange, but if we are not emitting a single patch or
cover letter, perhaps there is no place to emit the range-diff so it
may not get any complaint.

> Should the quoted <previous> argument to --range-diff be allowed, and
> forbid the unquoted counterpart?

No, I think the command is fine as-is.

Stepping back a bit, if you have two topics (perhaps related,
perhaps not) forked from the mainline, but you want to present
them as a single unit to the outside world, you may do this:

    $ git format-patch ^master topic-1 topic-2

If two topics share their early commits and their later commits are
independent and do not interact with each other, this command line
should do the right thing to emit shared ones only once.

If these were the second iteration, I would imagine

    $ git format-patch \
	--range-diff='^master@{last.week} topic-1@{last.week} topic-2@{last.week}' \
	^master topic-1 topic-2

would be a good way to include the range-diff for this round
relative to the previous round you sent last week.

So, quoting <previous> may be necessary in a more complex usecase,
but most of the time you should not have to quote.

HTH.

      reply	other threads:[~2021-10-08 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  9:34 git format-patch --range-diff accepts non-quoted arguments (shouldn't it be?) Bagas Sanjaya
2021-10-08 18:10 ` Junio C Hamano [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqq7denl750.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).