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
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2017, 21:31 UTC
Message-ID
<xmqq8tp88nnj.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170214212404.31469-2-cornelius.weig@tngtech.com>
cornelius.weig@tngtech.com writes:
Show 16 quoted lines
> 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.

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.

Previous: cornelius.weig@tngtech.comNext: Cornelius Weig
Message 6 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.