]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: tab completion of filenames for 'git restore'
authorDavid Cantrell <david@cantrell.org.uk>
Tue, 15 Mar 2022 22:13:57 +0000 (22:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2022 00:21:22 +0000 (17:21 -0700)
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>
contrib/completion/git-completion.bash

index 49a328aa8a4efef2272f7755506179dd1fc1129f..ba5c395d2d804f522d5730f7bca2fa6e17d63a96 100644 (file)
@@ -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
 }