git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: git@vger.kernel.org
Subject: [BUG] git checkout -p HEAD...
Date: Mon, 28 Sep 2020 23:18:30 -0700	[thread overview]
Message-ID: <20200929061830.GA40759@generichostname> (raw)

Hi all,

git checkout -p <commit>... is broken:

	$ git checkout HEAD... -p
	usage: git diff-index [-m] [--cached] [<common-diff-options>] <tree-ish> [<path>...]
	common diff options:
	  -z            output diff-raw with lines terminated with NUL.
	  -p            output patch format.
	  -u            synonym for -p.
	  --patch-with-raw
			output both a patch and the diff-raw format.
	  --stat        show diffstat instead of patch.
	  --numstat     show numeric diffstat instead of patch.
	  --patch-with-stat
			output a patch and prepend its diffstat.
	  --name-only   show only names of changed files.
	  --name-status show names and status of changed files.
	  --full-index  show full object name on index lines.
	  --abbrev=<n>  abbreviate object names in diff-tree header and diff-raw.
	  -R            swap input file pairs.
	  -B            detect complete rewrites.
	  -M            detect renames.
	  -C            detect copies.
	  --find-copies-harder
			try unchanged files as candidate for copy detection.
	  -l<n>         limit rename attempts up to <n> paths.
	  -O<file>      reorder diffs according to the <file>.
	  -S<string>    find filepair whose only one side contains the string.
	  --pickaxe-all
			show all files diff when -S is used and hit is found.
	  -a  --text    treat all files as text.

	Cannot close git diff-index --cached --numstat --summary HEAD... -- () at /home/denton/.local/libexec/git-core/git-add--interactive line 183.

The issue is simple: `HEAD...` is passed literally to `git diff-index`
which does not know how to handle it. The fix is simple: figure out the
OID and pass that instead.

One thing I'm not quite sure about is that in the documentation, the
restore-related checkout options accept <tree-ish> and it's an
implementation detail that the `<commit>...` form happens to work in the
non-patch case. In fact, `git restore --source=HEAD...` works too
(unless -p is given as well).

So I lean on the side of fully supporting the `...` form for `git
restore/checkout`. However, I understand if someone wishes to suggest
"that was never valid to begin with; we should prohibit `...` from
being used with restore-modes`.

Any opposition to fully supporting the `...` form?

Thanks,
Denton

             reply	other threads:[~2020-09-29  6:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29  6:18 Denton Liu [this message]
2020-09-29 16:02 ` 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=20200929061830.GA40759@generichostname \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    --subject='Re: [BUG] git checkout -p HEAD...' \
    /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

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).