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>

David Cantrell committed Mar 15, 2022 at 22:13 UTC 841fd28ce215ffeea4a291e7be533545c641396a
1 file changed +4
contrib/completion/git-completion.bash
+4
@@ -2890,6 +2890,10 @@ _git_restore ()
2890 --*)
2891 __gitcomp_builtin restore
2892 ;;
2893 + *)
2894 + if __git rev-parse --verify --quiet HEAD >/dev/null; then
2895 + __git_complete_index_file "--modified"
2896 + fi
2897 esac
2898 }
2899