git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] completion: checkout: complete paths when ref given

From
CWCornelius Weig <cornelius.weig@tngtech.com>
Date
Feb 14, 2017, 22:13 UTC
Message-ID
<9be8b988-f5b3-7365-ae7f-b46888253f4c@tngtech.com>
In-Reply-To
<xmqq8tp88nnj.fsf@gitster.mtv.corp.google.com>
On 02/14/2017 10:31 PM, Junio C Hamano wrote:
Show 25 quoted lines
> cornelius.weig@tngtech.com writes:
> 
>> From: Cornelius Weig <cornelius.weig@tngtech.com>
>>
>> Git-checkout completes words starting with '--' as options and other
>> words as refs. Even after specifying a ref, further words not starting
>> with '--' are completed as refs, which is invalid for git-checkout.
>>
>> This commit ensures that after specifying a ref, further non-option
>> words are completed as paths. Four cases are considered:
>>
>>  - If the word contains a ':', do not treat it as reference and use
>>    regular revlist completion.
>>  - If no ref is found on the command line, complete non-options as refs
>>    as before.
>>  - If the ref is HEAD or @, complete only with modified files because
>>    checking out unmodified files is a noop.
>>    This case also applies if no ref is given, but '--' is present.
> 
> Please at least do not do this one; a completion that is or pretends
> to be more clever than the end users will confuse them at best and
> annoy them.  Maybe the user does not recall if she touched the path
> or not, and just trying to be extra sure that it matches HEAD or
> index by doing "git checkout [HEAD] path<TAB>".  Leave the "make it
> a noop" to Git, but just allow her do so.

Hmm.. I'm a bit reluctant to let go of this just yet, because it was my original motivation for the whole patch. I admit that it may be confusing to not get completion in your example. However, I think that once acquainted with the new behavior, a user who wants some files cleaned would start by having a look at the list of files from "git checkout HEAD <TAB><TAB>". That's probably faster than spelling the first few characters and hit <TAB> for a file that's already clean. Let's hear if anybody else has an opinion about this.

> I personally feel that "git checkout <anything>... foo<TAB>" should
> just fall back to the normal "path on the filesystem" without any
> cleverness, instead of opening a tree object or peek into the index.

I was thinking about that as well, but it's not what happens for "git checkout topic:path<TAB>". And given that "git checkout topic path<TAB>" refers to the same object, consistency kind of demands that the tree objects are opened in the latter case as well. However, because the differences to filesystem path completion are somewhat corner cases, I'm fine with that as long as I'm not offered ref names any longer...

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 12 in “completion: complete modified files for checkout with '--'”
  1. completion: complete modified files for checkout with '--'cornelius.weig@tngtech.com, Feb 13, 2017
  2. SZEDER GáborFeb 14, 2017
  3. Cornelius WeigFeb 14, 2017
  4. 1/2 completion: extract utility to complete paths from tree-ishcornelius.weig@tngtech.com, Feb 14, 2017
  5. 2/2 completion: checkout: complete paths when ref givencornelius.weig@tngtech.com, Feb 14, 2017
  6. Junio C HamanoFeb 14, 2017
  7. Cornelius WeigFeb 14, 2017
  8. Junio C HamanoFeb 14, 2017
  9. SZEDER GáborFeb 15, 2017
  10. Cornelius WeigFeb 15, 2017
  11. SZEDER GáborFeb 15, 2017
  12. Cornelius WeigFeb 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.