Re: [PATCH] completion: complete tracked paths for 'git diff'
Junio C Hamano <[email protected]> Sun, 02 Aug 2026 18:07:31 -0700
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
Junio C Hamano <[email protected]> writes: > When completing arguments for 'git diff', _git_diff() delegates to > __git_complete_revlist_file(), which only completes revision > references. This is good [*], as mixing both revs and paths in a > single list to have the user pick is simply too confusing. > > If no reference matches, or if '--' is given, however, _git_diff() > leaves COMPREPLY empty. Bash then falls back to default filename > completion in $PWD. This fails when 'git -C <path>' is used because > $PWD is not the target repository. > > Update _git_diff() to use __git_complete_index_file() when '--' is > present, or when revision reference completion yields no matching > candidates, so that tracked paths are offered as candidates. This changes behavior even in the case where '-C <there>' is not used. The new behavior omits untracked paths from suggestions, which is clearly better behavior. I'll add the above paragraph to the proposed log message when I queue this on 'seen'.