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>

Cornelius Weig committed Feb 3, 2017 at 12:01 UTC bd9ab9dfc0b64128b10567906032c7f6e1d9bd67
1 file changed +7 -3
contrib/completion/git-completion.bash
+7 -3
@@ -947,13 +947,17 @@ _git_add ()
947 --*)
948 __gitcomp "
949 --interactive --refresh --patch --update --dry-run
950 - --ignore-errors --intent-to-add
950 + --ignore-errors --intent-to-add --force --edit --chmod=
951 "
952 return
953 esac
954
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"
961 }
962
963 _git_archive ()