Merge branch 'tr/maint-1.6.5-bash-prompt-show-submodule-changes'
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Jan 2010 16:52:32 +0000 (08:52 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Jan 2010 16:52:32 +0000 (08:52 -0800)
* tr/maint-1.6.5-bash-prompt-show-submodule-changes:
  bash completion: factor submodules into dirty state

1  2 
contrib/completion/git-completion.bash

  #    2) Added the following line to your .bashrc:
  #        source ~/.git-completion.sh
  #
 -#    3) You may want to make sure the git executable is available
 -#       in your PATH before this script is sourced, as some caching
 -#       is performed while the script loads.  If git isn't found
 -#       at source time then all lookups will be done on demand,
 -#       which may be slightly slower.
 -#
 -#    4) Consider changing your PS1 to also show the current branch:
 +#    3) Consider changing your PS1 to also show the current branch:
  #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
  #
  #       The argument to __git_ps1 will be displayed only if you
@@@ -142,11 -148,9 +142,9 @@@ __git_ps1 (
                elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
                        if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
                                if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
-                                       git diff --no-ext-diff --ignore-submodules \
-                                               --quiet --exit-code || w="*"
+                                       git diff --no-ext-diff --quiet --exit-code || w="*"
                                        if git rev-parse --quiet --verify HEAD >/dev/null; then
-                                               git diff-index --cached --quiet \
-                                                       --ignore-submodules HEAD -- || i="+"
+                                               git diff-index --cached --quiet HEAD -- || i="+"
                                        else
                                                i="#"
                                        fi
                        fi
                fi
  
 -              if [ -n "${1-}" ]; then
 -                      printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
 -              else
 -                      printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
 -              fi
 +              local f="$w$i$s$u"
 +              printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r"
        fi
  }
  
@@@ -315,8 -322,12 +313,8 @@@ __git_remotes (
        done
  }
  
 -__git_merge_strategies ()
 +__git_list_merge_strategies ()
  {
 -      if [ -n "${__git_merge_strategylist-}" ]; then
 -              echo "$__git_merge_strategylist"
 -              return
 -      fi
        git merge -s help 2>&1 |
        sed -n -e '/[Aa]vailable strategies are: /,/^$/{
                s/\.$//
                p
        }'
  }
 -__git_merge_strategylist=
 -__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
 +
 +__git_merge_strategies=
 +# 'git merge -s help' (and thus detection of the merge strategy
 +# list) fails, unfortunately, if run outside of any git working
 +# tree.  __git_merge_strategies is set to the empty string in
 +# that case, and the detection will be repeated the next time it
 +# is needed.
 +__git_compute_merge_strategies ()
 +{
 +      : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
 +}
  
  __git_complete_file ()
  {
@@@ -414,17 -416,7 +412,17 @@@ __git_complete_remote_or_refspec (
        while [ $c -lt $COMP_CWORD ]; do
                i="${COMP_WORDS[c]}"
                case "$i" in
 -              --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
 +              --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
 +              --all)
 +                      case "$cmd" in
 +                      push) no_complete_refspec=1 ;;
 +                      fetch)
 +                              COMPREPLY=()
 +                              return
 +                              ;;
 +                      *) ;;
 +                      esac
 +                      ;;
                -*) ;;
                *) remote="$i"; break ;;
                esac
  
  __git_complete_strategy ()
  {
 +      __git_compute_merge_strategies
        case "${COMP_WORDS[COMP_CWORD-1]}" in
        -s|--strategy)
 -              __gitcomp "$(__git_merge_strategies)"
 +              __gitcomp "$__git_merge_strategies"
                return 0
        esac
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --strategy=*)
 -              __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
 +              __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
                return 0
                ;;
        esac
        return 1
  }
  
 -__git_all_commands ()
 +__git_list_all_commands ()
  {
 -      if [ -n "${__git_all_commandlist-}" ]; then
 -              echo "$__git_all_commandlist"
 -              return
 -      fi
        local i IFS=" "$'\n'
        for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
        do
                esac
        done
  }
 -__git_all_commandlist=
 -__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
  
 -__git_porcelain_commands ()
 +__git_all_commands=
 +__git_compute_all_commands ()
 +{
 +      : ${__git_all_commands:=$(__git_list_all_commands)}
 +}
 +
 +__git_list_porcelain_commands ()
  {
 -      if [ -n "${__git_porcelain_commandlist-}" ]; then
 -              echo "$__git_porcelain_commandlist"
 -              return
 -      fi
        local i IFS=" "$'\n'
 -      for i in "help" $(__git_all_commands)
 +      __git_compute_all_commands
 +      for i in "help" $__git_all_commands
        do
                case $i in
                *--*)             : helper pattern;;
                esac
        done
  }
 -__git_porcelain_commandlist=
 -__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
 +
 +__git_porcelain_commands=
 +__git_compute_porcelain_commands ()
 +{
 +      __git_compute_all_commands
 +      : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
 +}
  
  __git_aliases ()
  {
@@@ -903,31 -892,11 +901,31 @@@ _git_commit (
  
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
 +      --cleanup=*)
 +              __gitcomp "default strip verbatim whitespace
 +                      " "" "${cur##--cleanup=}"
 +              return
 +              ;;
 +      --reuse-message=*)
 +              __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
 +              return
 +              ;;
 +      --reedit-message=*)
 +              __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
 +              return
 +              ;;
 +      --untracked-files=*)
 +              __gitcomp "all no normal" "" "${cur##--untracked-files=}"
 +              return
 +              ;;
        --*)
                __gitcomp "
                        --all --author= --signoff --verify --no-verify
                        --edit --amend --include --only --interactive
 -                      --dry-run
 +                      --dry-run --reuse-message= --reedit-message=
 +                      --reset-author --file= --message= --template=
 +                      --cleanup= --untracked-files --untracked-files=
 +                      --verbose --quiet
                        "
                return
        esac
@@@ -982,13 -951,11 +980,13 @@@ _git_diff (
  }
  
  __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
 -                      tkdiff vimdiff gvimdiff xxdiff araxis
 +                      tkdiff vimdiff gvimdiff xxdiff araxis p4merge
  "
  
  _git_difftool ()
  {
 +      __git_has_doubledash && return
 +
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --tool=*)
                return
                ;;
        --*)
 -              __gitcomp "--tool="
 +              __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
 +                      --base --ours --theirs
 +                      --no-renames --diff-filter= --find-copies-harder
 +                      --relative --ignore-submodules
 +                      --tool="
                return
                ;;
        esac
 -      COMPREPLY=()
 +      __git_complete_file
  }
  
  __git_fetch_options="
        --quiet --verbose --append --upload-pack --force --keep --depth=
 -      --tags --no-tags
 +      --tags --no-tags --all --prune --dry-run
  "
  
  _git_fetch ()
@@@ -1104,8 -1067,7 +1102,8 @@@ _git_grep (
                return
                ;;
        esac
 -      COMPREPLY=()
 +
 +      __gitcomp "$(__git_refs)"
  }
  
  _git_help ()
                return
                ;;
        esac
 -      __gitcomp "$(__git_all_commands)
 +      __git_compute_all_commands
 +      __gitcomp "$__git_all_commands
                attributes cli core-tutorial cvs-migration
                diffcore gitk glossary hooks ignore modules
                repository-layout tutorial tutorial-2
@@@ -1254,7 -1215,7 +1252,7 @@@ _git_log (
  
  __git_merge_options="
        --no-commit --no-stat --log --no-log --squash --strategy
 -      --commit --stat --no-squash --ff --no-ff
 +      --commit --stat --no-squash --ff --no-ff --ff-only
  "
  
  _git_merge ()
@@@ -1359,18 -1320,8 +1357,18 @@@ _git_rebase (
        fi
        __git_complete_strategy && return
        case "$cur" in
 +      --whitespace=*)
 +              __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
 +              return
 +              ;;
        --*)
 -              __gitcomp "--onto --merge --strategy --interactive"
 +              __gitcomp "
 +                      --onto --merge --strategy --interactive
 +                      --preserve-merges --stat --no-stat
 +                      --committer-date-is-author-date --ignore-date
 +                      --ignore-whitespace --whitespace=
 +                      "
 +
                return
        esac
        __gitcomp "$(__git_refs)"
@@@ -1474,8 -1425,7 +1472,8 @@@ _git_config (
                return
                ;;
        pull.twohead|pull.octopus)
 -              __gitcomp "$(__git_merge_strategies)"
 +              __git_compute_merge_strategies
 +              __gitcomp "$__git_merge_strategies"
                return
                ;;
        color.branch|color.diff|color.interactive|\
        pager.*)
                local pfx="${cur%.*}."
                cur="${cur#*.}"
 -              __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
 +              __git_compute_all_commands
 +              __gitcomp "$__git_all_commands" "$pfx" "$cur"
                return
                ;;
        remote.*.*)
@@@ -2019,7 -1968,7 +2017,7 @@@ _git_svn (
                init fetch clone rebase dcommit log find-rev
                set-tree commit-diff info create-ignore propget
                proplist show-ignore show-externals branch tag blame
 -              migrate
 +              migrate mkdirs reset gc
                "
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
                        __gitcomp "--stdin $cmt_opts $fc_opts"
                        ;;
                create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
 -              show-externals,--*)
 +              show-externals,--*|mkdirs,--*)
                        __gitcomp "--revision="
                        ;;
                log,--*)
                                --no-auth-cache --username=
                                "
                        ;;
 +              reset,--*)
 +                      __gitcomp "--revision= --parent"
 +                      ;;
                *)
                        COMPREPLY=()
                        ;;
@@@ -2177,8 -2123,7 +2175,8 @@@ _git (
                        --help
                        "
                        ;;
 -              *)     __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
 +              *)     __git_compute_porcelain_commands
 +                     __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
                esac
                return
        fi