{"thread":{"id":"54321","subject":"[BUG] git checkout -p HEAD...","startedAt":"2020-09-29T06:18:36Z","lastAt":"2020-09-29T16:02:10Z","messageCount":2,"participants":["Denton Liu","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"406619","messageId":"20200929061830.GA40759@generichostname","threadId":"54321","inReplyTo":null,"subject":"[BUG] git checkout -p HEAD...","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2020-09-29T06:18:30Z","receivedAt":"2020-09-29T06:18:36Z","isPatch":false,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi all,\n\ngit checkout -p <commit>... is broken:\n\n\t$ git checkout HEAD... -p\n\tusage: git diff-index [-m] [--cached] [<common-diff-options>] <tree-ish> [<path>...]\n\tcommon diff options:\n\t  -z            output diff-raw with lines terminated with NUL.\n\t  -p            output patch format.\n\t  -u            synonym for -p.\n\t  --patch-with-raw\n\t\t\toutput both a patch and the diff-raw format.\n\t  --stat        show diffstat instead of patch.\n\t  --numstat     show numeric diffstat instead of patch.\n\t  --patch-with-stat\n\t\t\toutput a patch and prepend its diffstat.\n\t  --name-only   show only names of changed files.\n\t  --name-status show names and status of changed files.\n\t  --full-index  show full object name on index lines.\n\t  --abbrev=<n>  abbreviate object names in diff-tree header and diff-raw.\n\t  -R            swap input file pairs.\n\t  -B            detect complete rewrites.\n\t  -M            detect renames.\n\t  -C            detect copies.\n\t  --find-copies-harder\n\t\t\ttry unchanged files as candidate for copy detection.\n\t  -l<n>         limit rename attempts up to <n> paths.\n\t  -O<file>      reorder diffs according to the <file>.\n\t  -S<string>    find filepair whose only one side contains the string.\n\t  --pickaxe-all\n\t\t\tshow all files diff when -S is used and hit is found.\n\t  -a  --text    treat all files as text.\n\n\tCannot close git diff-index --cached --numstat --summary HEAD... -- () at /home/denton/.local/libexec/git-core/git-add--interactive line 183.\n\nThe issue is simple: `HEAD...` is passed literally to `git diff-index`\nwhich does not know how to handle it. The fix is simple: figure out the\nOID and pass that instead.\n\nOne thing I'm not quite sure about is that in the documentation, the\nrestore-related checkout options accept <tree-ish> and it's an\nimplementation detail that the `<commit>...` form happens to work in the\nnon-patch case. In fact, `git restore --source=HEAD...` works too\n(unless -p is given as well).\n\nSo I lean on the side of fully supporting the `...` form for `git\nrestore/checkout`. However, I understand if someone wishes to suggest\n\"that was never valid to begin with; we should prohibit `...` from\nbeing used with restore-modes`.\n\nAny opposition to fully supporting the `...` form?\n\nThanks,\nDenton\n"},{"id":"406626","messageId":"xmqqlfgsinb7.fsf@gitster.c.googlers.com","threadId":"54321","inReplyTo":"20200929061830.GA40759@generichostname","subject":"Re: [BUG] git checkout -p HEAD...","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-29T16:02:04Z","receivedAt":"2020-09-29T16:02:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> So I lean on the side of fully supporting the `...` form for `git\n> restore/checkout`. However, I understand if someone wishes to suggest\n> \"that was never valid to begin with; we should prohibit `...` from\n> being used with restore-modes`.\n>\n> Any opposition to fully supporting the `...` form?\n\nNot from me.  The \"-p\" feature of various commands were bolted on as\na mere afterthought and in a rather hacky way. I am not surprised if\nquality of their implementation differs from that of the primary\ncodepaths.  It did not help that they are implemented by diverting\nthe control early to the \"add--interactive\" machinery from the\nprimary control flow, and it may be a large, if not primary, source\nof differences in how command line options are handled by the \"-p\"\ncodepath and the primary codepath in these commands.\n\nMaking \"-p\" behave more like the primary modes of operation in these\ncommands would be a welcome move, I would think.  I hope that it got\nmuch easier to access the \"add--interactive\" machinery from C these\ndays; probably it is a good time to make that move.\n\nThanks.\n"}]}