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

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

From
Elijah Newren <newren@gmail.com>
Date
Aug 7, 2026, 06:31 UTC
Message-ID
<CABPp-BE0WOD1jRT-fVqxP0uaVuV0-Qu4rqCyL63vaRCEiAUmAA@mail.gmail.com>
In-Reply-To
<20260807013830.698340-1-gitster@pobox.com>
On Thu, Aug 6, 2026 at 6:38 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
>
> 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.
>
> This series teaches the completion machinery to complete revisions
> (unless '--' exists), then tracked paths, and then untracked paths,
> before letting the Bash default kick in.  This way, we correctly
> complete 'git diff' command line even when '-C <directory>' is in
> effect.
Nice.  :-)
Show 7 quoted lines
> The tests are the only changes relative to v2.  In the step where
> tracked paths are completed, v2 did not demonstrate that untracked
> ones are *not* completed at the same time.  Now we do by having
> untracked 'file3' next to 'file1' and 'file2' that are tracked.  In
> the last step, we demonstrate untracked paths that do not share
> prefix with refs or tracked paths are completed, with or without the
> "-C <dir>" option.
I found this paragraph slightly hard to parse.  I think this means the same as:

Only the tests changed since v2. The tracked-paths step now also shows that untracked paths are not mixed in: an untracked 'file3' next to tracked 'file1'/'file2' means "git diff f" completes only the latter two. The untracked-paths step shows that an untracked path which shares no prefix with a ref or tracked path still completes, with or without "-C ".

(Not that it matters, since this is just the cover letter, but...)
>  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

I found two minor nits in the first two patches, and didn't spot any issues with the third patch.

Previous: Elijah NewrenNext: D. Ben Knoble
Message 24 of 34 in “completion: complete tracked paths for 'git diff'”
  1. completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 3, 2026
  2. Junio C HamanoAug 3, 2026
  3. SZEDER GáborAug 3, 2026
  4. Junio C HamanoAug 3, 2026
  5. Junio C HamanoAug 3, 2026
  6. completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 4, 2026
  7. 0/3 completion of 'git [-C <dir>] diff'Junio C Hamano, Aug 5, 2026
  8. 1/3 completion: no-op refactoring of diff completionJunio C Hamano, Aug 5, 2026
  9. 2/3 completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 5, 2026
  10. 3/3 completion: 'git diff' completes untracked paths as a last resortJunio C Hamano, Aug 5, 2026
  11. D. Ben KnobleAug 6, 2026
  12. Junio C HamanoAug 6, 2026
  13. D. Ben KnobleAug 6, 2026
  14. 0/3 completion of 'git [-C <dir>] diff'Junio C Hamano, Aug 7, 2026
  15. 1/3 completion: no-op refactoring of diff completionJunio C Hamano, Aug 7, 2026
  16. Elijah NewrenAug 7, 2026
  17. Junio C HamanoAug 7, 2026
  18. 3/3 completion: 'git diff' completes untracked paths as a last resortJunio C Hamano, Aug 7, 2026
  19. 2/3 completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 7, 2026
  20. Elijah NewrenAug 7, 2026
  21. D. Ben KnobleAug 7, 2026
  22. Junio C HamanoAug 7, 2026
  23. Elijah NewrenAug 7, 2026
  24. Elijah NewrenAug 7, 2026
  25. D. Ben KnobleAug 7, 2026
  26. 0/3 completion of 'git [-C <dir>] diff'Junio C Hamano, Aug 7, 2026
  27. 1/3 completion: no-op refactoring of diff completionJunio C Hamano, Aug 7, 2026
  28. 2/3 completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 7, 2026
  29. 3/3 completion: 'git diff' completes untracked paths as a last resortJunio C Hamano, Aug 7, 2026
  30. Elijah NewrenAug 7, 2026
  31. 0/3 completion of 'git [-C <dir>] diff'Junio C Hamano, Aug 12, 2026
  32. 1/3 completion: no-op refactoring of diff completionJunio C Hamano, Aug 12, 2026
  33. 2/3 completion: complete tracked paths for 'git diff'Junio C Hamano, Aug 12, 2026
  34. 3/3 completion: 'git diff' completes untracked paths as a last resortJunio C Hamano, Aug 12, 2026

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.