Kyle Lippincott <spectral@xxxxxxxxxx> writes: >> ... >> But the same does not work for the step before I can decide to >> actually "add" the contents, which is to "diff", i.e. >> >> $ git -C Meta diff whats-<TAB> >> >> does not complete. > > I'm not a completions expert, but I think what's happening is that the > completions for `git diff` aren't producing anything, so it (where > "it" here might be the shell?) falls back to just doing normal path > completion. Yes, that seems to be the case. > For `git add`, it's checking the `git status` output to > filter the list to things that need to be added,... Not exactly, but a close enough description, I think. __git_complete_index_file does not run `git status` but asks ls-files the paths it knows about (including "--others" so that a path that is untracked can become a candidate to be added), then massages the list of paths with a custom awk script. For "git diff", depending on what two sets of contents are being compared, the source of possible paths may differ, but the list of paths obtained from ls-files (without --others) would be appropriate when comparing the index and the working tree files, or comparing a tree-ish and the working tree files. The necessary ingredient to do so may be pretty much the same as what is used by _git_add completion. When comparing two tree-ishes, the candidate would ideally come from union of paths in these two tree-ishes, but I offhand do not know if there already is a support for choosing from such a set. Thanks.