Thread (34 messages) flat view 34 messages, 4 authors, 18d ago
COLD18d

Revision v3 of 4 in this series.

Revisions (4)
  1. v3 current
  2. v4 [diff vs current]
  3. v5 [diff vs current]
  4. v6 [diff vs current]

[PATCH v3 0/3] completion of 'git [-C <dir>] diff'

From: Junio C Hamano <hidden>
Date: 2026-08-05 19:42:53

Here is another reroll.

The primary motivation for this topic is that the command-line
completion of 'git diff' does not handle paths (unlike 'git status'
and 'git add') and instead relies on the default behavior of Bash
command-line completion, which completes files in $PWD; this does
not work at all with the '-C <directory>' option.

Previous iterations of the patch taught the completion script to
offer tracked paths that match the prefix before <TAB> to improve
the situation.

This time, we also complete untracked paths ourselves, so that even
the following commands, which compare files like 'file[12]' that are
not under the control of Git in a different directory, are
completed:

        $ git -C not-a-git-dir diff fil<TAB>
        $ git -C not-a-git-dir diff --no-index fil<TAB>

 1/3: completion: no-op refactoring of diff completion
 2/3: completion: complete tracked paths for 'git diff'
 3/3: completion: 'git diff' completes untracked paths as a last resort

 contrib/completion/git-completion.bash | 69 +++++++++++++++-----------
 t/t9902-completion.sh                  | 59 ++++++++++++++++++++++
 2 files changed, 100 insertions(+), 28 deletions(-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help