Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Dec 2010 00:41:13 +0000 (16:41 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Dec 2010 00:41:13 +0000 (16:41 -0800)
* maint:
add: introduce add.ignoreerrors synonym for add.ignore-errors
bash: Match lightweight tags in prompt
git-commit.txt: (synopsis): move -i and -o before "--"

1  2 
Documentation/config.txt
builtin/add.c
contrib/completion/git-completion.bash
diff --combined Documentation/config.txt
index 6a6c0b5bd83774c9c92f5530f327019c322d3c2a,3fd4b626fa84deb317709f11782534f36df36033..6b7279f88303e2d7a45baa27022cb9e53cf387be
@@@ -459,12 -459,6 +459,12 @@@ core.askpass:
        prompt. The external program shall be given a suitable prompt as
        command line argument and write the password on its STDOUT.
  
 +core.attributesfile::
 +      In addition to '.gitattributes' (per-directory) and
 +      '.git/info/attributes', git looks into this file for attributes
 +      (see linkgit:gitattributes[5]). Path expansions are made the same
 +      way as for `core.excludesfile`.
 +
  core.editor::
        Commands such as `commit` and `tag` that lets you edit
        messages by launching an editor uses the value of this
@@@ -554,9 -548,13 +554,13 @@@ core.sparseCheckout:
        linkgit:git-read-tree[1] for more information.
  
  add.ignore-errors::
+ add.ignoreErrors::
        Tells 'git add' to continue adding files when some files cannot be
        added due to indexing errors. Equivalent to the '--ignore-errors'
-       option of linkgit:git-add[1].
+       option of linkgit:git-add[1].  Older versions of git accept only
+       `add.ignore-errors`, which does not follow the usual naming
+       convention for configuration variables.  Newer versions of git
+       honor `add.ignoreErrors` as well.
  
  alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
@@@ -601,9 -599,8 +605,9 @@@ branch.autosetupmerge:
        this behavior can be chosen per-branch using the `--track`
        and `--no-track` options. The valid settings are: `false` -- no
        automatic setup is done; `true` -- automatic setup is done when the
 -      starting point is a remote branch; `always` -- automatic setup is
 -      done when the starting point is either a local branch or remote
 +      starting point is a remote-tracking branch; `always` --
 +      automatic setup is done when the starting point is either a
 +      local branch or remote-tracking
        branch. This option defaults to true.
  
  branch.autosetuprebase::
        When `local`, rebase is set to true for tracked branches of
        other local branches.
        When `remote`, rebase is set to true for tracked branches of
 -      remote branches.
 +      remote-tracking branches.
        When `always`, rebase will be set to true for all tracking
        branches.
        See "branch.autosetupmerge" for details on how to set up a
@@@ -681,7 -678,7 +685,7 @@@ color.branch:
  color.branch.<slot>::
        Use customized color for branch coloration. `<slot>` is one of
        `current` (the current branch), `local` (a local branch),
 -      `remote` (a tracking branch in refs/remotes/), `plain` (other
 +      `remote` (a remote-tracking branch in refs/remotes/), `plain` (other
        refs).
  +
  The value for these configuration variables is a list of colors (at most
@@@ -709,7 -706,7 +713,7 @@@ color.diff.<slot>:
  color.decorate.<slot>::
        Use customized color for 'git log --decorate' output.  `<slot>` is one
        of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local
 -      branches, remote tracking branches, tags, stash and HEAD, respectively.
 +      branches, remote-tracking branches, tags, stash and HEAD, respectively.
  
  color.grep::
        When set to `always`, always highlight matches.  When `false` (or
@@@ -1103,7 -1100,7 +1107,7 @@@ gui.newbranchtemplate:
        linkgit:git-gui[1].
  
  gui.pruneduringfetch::
 -      "true" if linkgit:git-gui[1] should prune tracking branches when
 +      "true" if linkgit:git-gui[1] should prune remote-tracking branches when
        performing a fetch. The default value is "false".
  
  gui.trustmtime::
@@@ -1738,7 -1735,6 +1742,7 @@@ sendemail.to:
  sendemail.smtpdomain::
  sendemail.smtpserver::
  sendemail.smtpserverport::
 +sendemail.smtpserveroption::
  sendemail.smtpuser::
  sendemail.thread::
  sendemail.validate::
diff --combined builtin/add.c
index 71f9b04fef829ad3725ca50902bd6935dc3cda36,3a5fca51590db53747f8712f733aa01e5840d8fb..21dc1f73395b5f6b1491c235f656bea057092eb1
@@@ -313,13 -313,13 +313,13 @@@ static int verbose = 0, show_only = 0, 
  static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
  
  static struct option builtin_add_options[] = {
 -      OPT__DRY_RUN(&show_only),
 -      OPT__VERBOSE(&verbose),
 +      OPT__DRY_RUN(&show_only, "dry run"),
 +      OPT__VERBOSE(&verbose, "be verbose"),
        OPT_GROUP(""),
        OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
        OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
        OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"),
 -      OPT_BOOLEAN('f', "force", &ignored_too, "allow adding otherwise ignored files"),
 +      OPT__FORCE(&ignored_too, "allow adding otherwise ignored files"),
        OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
        OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, "record only the fact that the path will be added later"),
        OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
  
  static int add_config(const char *var, const char *value, void *cb)
  {
-       if (!strcasecmp(var, "add.ignore-errors")) {
+       if (!strcasecmp(var, "add.ignoreerrors") ||
+           !strcasecmp(var, "add.ignore-errors")) {
                ignore_add_errors = git_config_bool(var, value);
                return 0;
        }
index f71046947febee2cacfd2a9ed2e0746582a5e54f,d3037fc94eb027e5067b0371da2b33081fd89da5..604fa794cc4d2dd657f054f42e3001bee13b8202
  #    2) Added the following line to your .bashrc:
  #        source ~/.git-completion.sh
  #
 +#       Or, add the following lines to your .zshrc:
 +#        autoload bashcompinit
 +#        bashcompinit
 +#        source ~/.git-completion.sh
 +#
  #    3) Consider changing your PS1 to also show the current branch:
  #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
  #
@@@ -143,12 -138,11 +143,12 @@@ __git_ps1_show_upstream (
                # get the upstream from the "git-svn-id: ..." in a commit message
                # (git-svn uses essentially the same procedure internally)
                local svn_upstream=($(git log --first-parent -1 \
 -                                      --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null))
 +                                      --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
                if [[ 0 -ne ${#svn_upstream[@]} ]]; then
                        svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
                        svn_upstream=${svn_upstream%@*}
 -                      for ((n=1; "$n" <= "${#svn_remote[@]}"; ++n)); do
 +                      local n_stop="${#svn_remote[@]}"
 +                      for ((n=1; n <= n_stop; ++n)); do
                                svn_upstream=${svn_upstream#${svn_remote[$n]}}
                        done
  
@@@ -261,7 -255,7 +261,7 @@@ __git_ps1 (
                                (describe)
                                        git describe HEAD ;;
                                (* | default)
-                                       git describe --exact-match HEAD ;;
+                                       git describe --tags --exact-match HEAD ;;
                                esac 2>/dev/null)" ||
  
                                b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
@@@ -386,19 -380,16 +386,19 @@@ __git_tags (
        done
  }
  
 -# __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
 +# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
 +# presence of 2nd argument means use the guess heuristic employed
 +# by checkout for tracking branches
  __git_refs ()
  {
 -      local i is_hash=y dir="$(__gitdir "${1-}")"
 +      local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
        local cur="${COMP_WORDS[COMP_CWORD]}" format refs
        if [ -d "$dir" ]; then
                case "$cur" in
                refs|refs/*)
                        format="refname"
                        refs="${cur%/*}"
 +                      track=""
                        ;;
                *)
                        for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
                esac
                git --git-dir="$dir" for-each-ref --format="%($format)" \
                        $refs
 +              if [ -n "$track" ]; then
 +                      # employ the heuristic used by git checkout
 +                      # Try to find a remote branch that matches the completion word
 +                      # but only output if the branch name is unique
 +                      local ref entry
 +                      git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
 +                              "refs/remotes/" | \
 +                      while read entry; do
 +                              eval "$entry"
 +                              ref="${ref#*/}"
 +                              if [[ "$ref" == "$cur"* ]]; then
 +                                      echo "$ref"
 +                              fi
 +                      done | uniq -u
 +              fi
                return
        fi
        for i in $(git ls-remote "$dir" 2>/dev/null); do
@@@ -774,19 -750,6 +774,19 @@@ __git_compute_porcelain_commands (
        : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
  }
  
 +__git_pretty_aliases ()
 +{
 +      local i IFS=$'\n'
 +      for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
 +              case "$i" in
 +              pretty.*)
 +                      i="${i#pretty.}"
 +                      echo "${i/ */}"
 +                      ;;
 +              esac
 +      done
 +}
 +
  __git_aliases ()
  {
        local i IFS=$'\n'
@@@ -944,16 -907,12 +944,16 @@@ _git_bisect (
        local subcommands="start bad good skip reset visualize replay log run"
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
 -              __gitcomp "$subcommands"
 +              if [ -f "$(__gitdir)"/BISECT_START ]; then
 +                      __gitcomp "$subcommands"
 +              else
 +                      __gitcomp "replay start"
 +              fi
                return
        fi
  
        case "$subcommand" in
 -      bad|good|reset|skip)
 +      bad|good|reset|skip|start)
                __gitcomp "$(__git_refs)"
                ;;
        *)
@@@ -1029,13 -988,7 +1029,13 @@@ _git_checkout (
                        "
                ;;
        *)
 -              __gitcomp "$(__git_refs)"
 +              # check if --track, --no-track, or --no-guess was specified
 +              # if so, disable DWIM mode
 +              local flags="--track --no-track --no-guess" track=1
 +              if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
 +                      track=''
 +              fi
 +              __gitcomp "$(__git_refs '' $track)"
                ;;
        esac
  }
@@@ -1415,12 -1368,12 +1415,12 @@@ _git_log (
        fi
        case "$cur" in
        --pretty=*)
 -              __gitcomp "$__git_log_pretty_formats
 +              __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
                        " "" "${cur##--pretty=}"
                return
                ;;
        --format=*)
 -              __gitcomp "$__git_log_pretty_formats
 +              __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
                        " "" "${cur##--format=}"
                return
                ;;
@@@ -1515,50 -1468,18 +1515,50 @@@ _git_name_rev (
  
  _git_notes ()
  {
 -      local subcommands="edit show"
 -      if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
 -              __gitcomp "$subcommands"
 -              return
 -      fi
 +      local subcommands='add append copy edit list prune remove show'
 +      local subcommand="$(__git_find_on_cmdline "$subcommands")"
 +      local cur="${COMP_WORDS[COMP_CWORD]}"
  
 -      case "${COMP_WORDS[COMP_CWORD-1]}" in
 -      -m|-F)
 -              COMPREPLY=()
 +      case "$subcommand,$cur" in
 +      ,--*)
 +              __gitcomp '--ref'
 +              ;;
 +      ,*)
 +              case "${COMP_WORDS[COMP_CWORD-1]}" in
 +              --ref)
 +                      __gitcomp "$(__git_refs)"
 +                      ;;
 +              *)
 +                      __gitcomp "$subcommands --ref"
 +                      ;;
 +              esac
 +              ;;
 +      add,--reuse-message=*|append,--reuse-message=*)
 +              __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
 +              ;;
 +      add,--reedit-message=*|append,--reedit-message=*)
 +              __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
 +              ;;
 +      add,--*|append,--*)
 +              __gitcomp '--file= --message= --reedit-message=
 +                              --reuse-message='
 +              ;;
 +      copy,--*)
 +              __gitcomp '--stdin'
 +              ;;
 +      prune,--*)
 +              __gitcomp '--dry-run --verbose'
 +              ;;
 +      prune,*)
                ;;
        *)
 -              __gitcomp "$(__git_refs)"
 +              case "${COMP_WORDS[COMP_CWORD-1]}" in
 +              -m|-F)
 +                      ;;
 +              *)
 +                      __gitcomp "$(__git_refs)"
 +                      ;;
 +              esac
                ;;
        esac
  }
@@@ -2179,12 -2100,12 +2179,12 @@@ _git_show (
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --pretty=*)
 -              __gitcomp "$__git_log_pretty_formats
 +              __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
                        " "" "${cur##--pretty=}"
                return
                ;;
        --format=*)
 -              __gitcomp "$__git_log_pretty_formats
 +              __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
                        " "" "${cur##--format=}"
                return
                ;;
@@@ -2418,11 -2339,6 +2418,11 @@@ _git (
  {
        local i c=1 command __git_dir
  
 +      if [[ -n ${ZSH_VERSION-} ]]; then
 +              emulate -L bash
 +              setopt KSH_TYPESET
 +      fi
 +
        while [ $c -lt $COMP_CWORD ]; do
                i="${COMP_WORDS[c]}"
                case "$i" in
        fi
  
        local completion_func="_git_${command//-/_}"
 -      declare -F $completion_func >/dev/null && $completion_func && return
 +      declare -f $completion_func >/dev/null && $completion_func && return
  
        local expansion=$(__git_aliased_command "$command")
        if [ -n "$expansion" ]; then
                completion_func="_git_${expansion//-/_}"
 -              declare -F $completion_func >/dev/null && $completion_func
 +              declare -f $completion_func >/dev/null && $completion_func
        fi
  }
  
  _gitk ()
  {
 +      if [[ -n ${ZSH_VERSION-} ]]; then
 +              emulate -L bash
 +              setopt KSH_TYPESET
 +      fi
 +
        __git_has_doubledash && return
  
        local cur="${COMP_WORDS[COMP_CWORD]}"
@@@ -2506,29 -2417,3 +2506,29 @@@ if [ Cygwin = "$(uname -o 2>/dev/null)
  complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
        || complete -o default -o nospace -F _git git.exe
  fi
 +
 +if [[ -n ${ZSH_VERSION-} ]]; then
 +      shopt () {
 +              local option
 +              if [ $# -ne 2 ]; then
 +                      echo "USAGE: $0 (-q|-s|-u) <option>" >&2
 +                      return 1
 +              fi
 +              case "$2" in
 +              nullglob)
 +                      option="$2"
 +                      ;;
 +              *)
 +                      echo "$0: invalid option: $2" >&2
 +                      return 1
 +              esac
 +              case "$1" in
 +              -q)     setopt | grep -q "$option" ;;
 +              -u)     unsetopt "$option" ;;
 +              -s)     setopt "$option" ;;
 +              *)
 +                      echo "$0: invalid flag: $1" >&2
 +                      return 1
 +              esac
 +      }
 +fi