git/contrib
Junio C Hamano 4b1b7a4e95 completion: complete tracked paths for 'git diff'
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 revisions and paths in a
single list for the user to pick from 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 when
no revs match the prefix but matching tracked paths exist, which is
more useful in the context of 'git diff'.

When run outside the working tree of a repository, or when nothing
matches from revisions or tracked paths, Bash still falls back to
default filename completion in $PWD, so such a use case would be
just like completing paths for any 'diff' command, rather than for
'git diff'.

[Footnote]
 * In https://lore.kernel.org/git/al%2Fw2qgBfhe9qMg6@szeder.dev/
   SZEDER made the same argument for "git send-email 0<TAB>".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-12 10:14:42 -07:00
..
buildsystems Merge branch 'pt/fsmonitor-linux' 2026-05-31 10:00:38 +09:00
completion completion: complete tracked paths for 'git diff' 2026-08-12 10:14:42 -07:00
contacts meson: make GIT_HTML_PATH configurable 2025-11-06 09:58:56 -08:00
credential osxkeychain: define build targets in the top-level Makefile. 2026-02-20 08:10:59 -08:00
diff-highlight diff-highlight: fetch all config with one process 2026-03-23 07:42:27 -07:00
fast-import
git-jump git-jump: pick a mode automatically when invoked without arguments 2026-05-21 23:01:04 +09:00
git-shell-commands
libgit-rs libgit: add higher-level libgit crate 2025-01-29 15:06:50 -08:00
libgit-sys libgit: add higher-level libgit crate 2025-01-29 15:06:50 -08:00
long-running-filter contrib/long-running-filter: *.txt -> *.adoc fixes 2025-03-03 13:49:22 -08:00
stats contrib: remove some scripts in "stats" directory 2025-05-12 10:55:47 -07:00
subtree docs: fix typos and grammar 2026-05-30 07:07:27 +09:00
vscode mingw: drop the build-system plumbing for nedmalloc 2026-05-09 11:19:23 +09:00
Makefile test: optionally test contrib in CI 2026-02-05 09:26:18 -08:00
README
meson.build contrib: move "coccinelle/" directory into "tools/" 2026-03-19 06:40:08 -07:00
rerere-train.sh

README

Contributed Software

Although these pieces are available as part of the official git
source tree, they are in somewhat different status.  The
intention is to keep interesting tools around git here, maybe
even experimental ones, to give users an easier access to them,
and to give tools wider exposure, so that they can be improved
faster.

I am not expecting to touch these myself that much.  As far as
my day-to-day operation is concerned, these subdirectories are
owned by their respective primary authors.  I am willing to help
if users of these components and the contrib/ subtree "owners"
have technical/design issues to resolve, but the initiative to
fix and/or enhance things _must_ be on the side of the subtree
owners.  IOW, I won't be actively looking for bugs and rooms for
enhancements in them as the git maintainer -- I may only do so
just as one of the users when I want to scratch my own itch.  If
you have patches to things in contrib/ area, the patch should be
first sent to the primary author, and then the primary author
should ack and forward it to me (git pull request is nicer).
This is the same way as how I have been treating gitk, and to a
lesser degree various foreign SCM interfaces, so you know the
drill.

I expect things that start their life in the contrib/ area
to graduate out of contrib/ once they mature, either by becoming
projects on their own, or moving to the toplevel directory.  On
the other hand, I expect I'll be proposing removal of disused
and inactive ones from time to time.

If you have new things to add to this area, please first propose
it on the git mailing list, and after a list discussion proves
there is general interest (it does not have to be a
list-wide consensus for a tool targeted to a relatively narrow
audience -- for example I do not work with projects whose
upstream is svn, so I have no use for git-svn myself, but it is
of general interest for people who need to interoperate with SVN
repositories in a way git-svn works better than git-svnimport),
submit a patch to create a subdirectory of contrib/ and put your
stuff there.

-jc