Skip to content

Commit 841fd28

Browse files
DrHydegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b896f72 commit 841fd28

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,10 @@ _git_restore ()
28902890
--*)
28912891
__gitcomp_builtin restore
28922892
;;
2893+
*)
2894+
if __git rev-parse --verify --quiet HEAD >/dev/null; then
2895+
__git_complete_index_file "--modified"
2896+
fi
28932897
esac
28942898
}
28952899

0 commit comments

Comments
 (0)