diff options
author | David Cantrell <david@cantrell.org.uk> | 2022-03-16 01:13:57 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-16 03:21:22 +0300 |
commit | 841fd28ce215ffeea4a291e7be533545c641396a (patch) | |
tree | ec832d1c60bec25c97df62561ac6c07c74ea60e5 /contrib | |
parent | b896f729e240d250cf56899e6a0073f6aa469f5d (diff) |
completion: tab completion of filenames for 'git restore'
If no --args are present after 'git restore', it assumes that you
want to tab-complete one of the files with unstaged uncommitted
changes.
If a file has been staged, we don't want to list it, as restoring those
requires a slightly more complex `git restore --staged`, so we only list
those files that are --modified. While --committable also looks like
a good candidate, that includes changes that have been staged.
Signed-off-by: David Cantrell <david@cantrell.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/completion/git-completion.bash | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 49a328aa8a..ba5c395d2d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2890,6 +2890,10 @@ _git_restore () --*) __gitcomp_builtin restore ;; + *) + if __git rev-parse --verify --quiet HEAD >/dev/null; then + __git_complete_index_file "--modified" + fi esac } |