Skip to content

Commit bd9ab9d

Browse files
Cornelius Weiggitster
authored andcommitted
completion: improve bash completion for git-add
Command completion for git-add did not recognize some long-options. This commits adds completion for all long-options that are mentioned in the man-page synopsis. In addition, if the user specified `--update` or `-u`, path completion will only suggest modified tracked files. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com> Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e24a256 commit bd9ab9d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

contrib/completion/git-completion.bash

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,13 +947,17 @@ _git_add ()
947947
--*)
948948
__gitcomp "
949949
--interactive --refresh --patch --update --dry-run
950-
--ignore-errors --intent-to-add
950+
--ignore-errors --intent-to-add --force --edit --chmod=
951951
"
952952
return
953953
esac
954954

955-
# XXX should we check for --update and --all options ?
956-
__git_complete_index_file "--others --modified --directory --no-empty-directory"
955+
local complete_opt="--others --modified --directory --no-empty-directory"
956+
if test -n "$(__git_find_on_cmdline "-u --update")"
957+
then
958+
complete_opt="--modified"
959+
fi
960+
__git_complete_index_file "$complete_opt"
957961
}
958962

959963
_git_archive ()

0 commit comments

Comments
 (0)