Code

bash completion: only show 'log --merge' if merging
authorThomas Rast <trast@student.ethz.ch>
Mon, 16 Feb 2009 16:34:57 +0000 (17:34 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Feb 2009 18:41:45 +0000 (10:41 -0800)
The gitk completion only shows --merge if MERGE_HEAD is present.
Do it the same way for git-log completion.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 6e5260ee7526975bf22b5031bd720a7a323bcf29..0a3092f646872867b0060d79c0fd1c85a40e24f4 100755 (executable)
@@ -1003,6 +1003,11 @@ _git_log ()
        __git_has_doubledash && return
 
        local cur="${COMP_WORDS[COMP_CWORD]}"
+       local g="$(git rev-parse --git-dir 2>/dev/null)"
+       local merge=""
+       if [ -f $g/MERGE_HEAD ]; then
+               merge="--merge"
+       fi
        case "$cur" in
        --pretty=*)
                __gitcomp "$__git_log_pretty_formats
@@ -1030,7 +1035,7 @@ _git_log ()
                        --decorate
                        --walk-reflogs
                        --parents --children
-                       --merge
+                       $merge
                        $__git_diff_common_options
                        --pickaxe-all --pickaxe-regex
                        "