* [BUG] git checkout -p HEAD...
@ 2020-09-29 6:18 Denton Liu
2020-09-29 16:02 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Denton Liu @ 2020-09-29 6:18 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] git checkout -p HEAD...
2020-09-29 6:18 [BUG] git checkout -p HEAD Denton Liu
@ 2020-09-29 16:02 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2020-09-29 16:02 UTC (permalink / raw)
To: Denton Liu; +Cc: git
Denton Liu <liu.denton@gmail.com> writes:
> 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?
Not from me. The "-p" feature of various commands were bolted on as
a mere afterthought and in a rather hacky way. I am not surprised if
quality of their implementation differs from that of the primary
codepaths. It did not help that they are implemented by diverting
the control early to the "add--interactive" machinery from the
primary control flow, and it may be a large, if not primary, source
of differences in how command line options are handled by the "-p"
codepath and the primary codepath in these commands.
Making "-p" behave more like the primary modes of operation in these
commands would be a welcome move, I would think. I hope that it got
much easier to access the "add--interactive" machinery from C these
days; probably it is a good time to make that move.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-29 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 6:18 [BUG] git checkout -p HEAD Denton Liu
2020-09-29 16:02 ` Junio C Hamano
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).