]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: improve bash completion for git-add
authorCornelius Weig <cornelius.weig@tngtech.com>
Fri, 3 Feb 2017 11:01:55 +0000 (12:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 4 Feb 2017 06:25:46 +0000 (22:25 -0800)
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>
contrib/completion/git-completion.bash

index d1a43f9381868d6bf89013f5b2efa63c637374f5..bfa3afb4c130d05744b94e9993422b2941b06d07 100644 (file)
@@ -947,13 +947,17 @@ _git_add ()
        --*)
                __gitcomp "
                        --interactive --refresh --patch --update --dry-run
-                       --ignore-errors --intent-to-add
+                       --ignore-errors --intent-to-add --force --edit --chmod=
                        "
                return
        esac
 
-       # XXX should we check for --update and --all options ?
-       __git_complete_index_file "--others --modified --directory --no-empty-directory"
+       local complete_opt="--others --modified --directory --no-empty-directory"
+       if test -n "$(__git_find_on_cmdline "-u --update")"
+       then
+               complete_opt="--modified"
+       fi
+       __git_complete_index_file "$complete_opt"
 }
 
 _git_archive ()