Merge branch 'pg/maint-1.7.9-am-where-is-patch'
authorJunio C Hamano <gitster@pobox.com>
Sun, 22 Jul 2012 19:56:02 +0000 (12:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Jul 2012 19:56:02 +0000 (12:56 -0700)
When "git am" failed, old timers knew to check .git/rebase-apply/patch
to see what went wrong, but we never told the users about it.

* pg/maint-1.7.9-am-where-is-patch:
am: indicate where a failed patch is to be found

1  2 
Documentation/config.txt
git-am.sh
diff --combined Documentation/config.txt
index 7bc0e5384871dc4c10df038cacee7c9d9370c4da,b1f0a75c6fe4404dc511ee1410ba5f948270a0b2..a95e5a4ac9a7e35623ada63d7919b193d7f86a6e
@@@ -86,19 -86,6 +86,19 @@@ customary UNIX fashion
  
  Some variables may require a special value format.
  
 +Includes
 +~~~~~~~~
 +
 +You can include one config file from another by setting the special
 +`include.path` variable to the name of the file to be included. The
 +included file is expanded immediately, as if its contents had been
 +found at the location of the include directive. If the value of the
 +`include.path` variable is a relative path, the path is considered to be
 +relative to the configuration file in which the include directive was
 +found. The value of `include.path` is subject to tilde expansion: `~/`
 +is expanded to the value of `$HOME`, and `~user/` to the specified
 +user's home directory. See below for examples.
 +
  Example
  ~~~~~~~
  
                gitProxy="ssh" for "kernel.org"
                gitProxy=default-proxy ; for the rest
  
 +      [include]
 +              path = /path/to/foo.inc ; include by absolute path
 +              path = foo ; expand "foo" relative to the current file
 +              path = ~/foo ; expand "foo" in your $HOME directory
 +
  Variables
  ~~~~~~~~~
  
@@@ -141,28 -123,12 +141,28 @@@ advice.*:
  +
  --
        pushNonFastForward::
 -              Advice shown when linkgit:git-push[1] refuses
 -              non-fast-forward refs.
 +              Set this variable to 'false' if you want to disable
 +              'pushNonFFCurrent', 'pushNonFFDefault', and
 +              'pushNonFFMatching' simultaneously.
 +      pushNonFFCurrent::
 +              Advice shown when linkgit:git-push[1] fails due to a
 +              non-fast-forward update to the current branch.
 +      pushNonFFDefault::
 +              Advice to set 'push.default' to 'upstream' or 'current'
 +              when you ran linkgit:git-push[1] and pushed 'matching
 +              refs' by default (i.e. you did not provide an explicit
 +              refspec, and no 'push.default' configuration was set)
 +              and it resulted in a non-fast-forward error.
 +      pushNonFFMatching::
 +              Advice shown when you ran linkgit:git-push[1] and pushed
 +              'matching refs' explicitly (i.e. you used ':', or
 +              specified a refspec that isn't your current branch) and
 +              it resulted in a non-fast-forward error.
        statusHints::
 -              Directions on how to stage/unstage/add shown in the
 -              output of linkgit:git-status[1] and the template shown
 -              when writing commit messages.
 +              Show directions on how to proceed from the current
 +              state in the output of linkgit:git-status[1] and in
 +              the template shown when writing commit messages in
 +              linkgit:git-commit[1].
        commitBeforeMerge::
                Advice shown when linkgit:git-merge[1] refuses to
                merge to avoid overwriting local changes.
                Advice shown when you used linkgit:git-checkout[1] to
                move to the detach HEAD state, to instruct how to create
                a local branch after the fact.
+       amWorkDir::
+               Advice that shows the location of the patch file when
+               linkgit:git-am[1] fails to apply it.
  --
  
  core.fileMode::
@@@ -211,15 -180,6 +214,15 @@@ The default is false, except linkgit:gi
  will probe and set core.ignorecase true if appropriate when the repository
  is created.
  
 +core.precomposeunicode::
 +      This option is only used by Mac OS implementation of git.
 +      When core.precomposeunicode=true, git reverts the unicode decomposition
 +      of filenames done by Mac OS. This is useful when sharing a repository
 +      between Mac OS and Linux or Windows.
 +      (Git for Windows 1.7.10 or higher is needed, or git under cygwin 1.7).
 +      When false, file names are handled fully transparent by git,
 +      which is backward compatible with older versions of git.
 +
  core.trustctime::
        If false, the ctime differences between the index and the
        working tree are ignored; useful when the inode change time
@@@ -491,11 -451,9 +494,11 @@@ Common unit suffixes of 'k', 'm', or 'g
  core.excludesfile::
        In addition to '.gitignore' (per-directory) and
        '.git/info/exclude', git looks into this file for patterns
 -      of files which are not meant to be tracked.  "{tilde}/" is expanded
 -      to the value of `$HOME` and "{tilde}user/" to the specified user's
 -      home directory.  See linkgit:gitignore[5].
 +      of files which are not meant to be tracked.  "`~/`" is expanded
 +      to the value of `$HOME` and "`~user/`" to the specified user's
 +      home directory. Its default value is $XDG_CONFIG_HOME/git/ignore.
 +      If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore
 +      is used instead. See linkgit:gitignore[5].
  
  core.askpass::
        Some commands (e.g. svn and http interfaces) that interactively
@@@ -510,9 -468,7 +513,9 @@@ 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`.
 +      way as for `core.excludesfile`. Its default value is
 +      $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not
 +      set or empty, $HOME/.config/git/attributes is used instead.
  
  core.editor::
        Commands such as `commit` and `tag` that lets you edit
@@@ -870,44 -826,6 +873,44 @@@ color.ui:
        `never` if you prefer git commands not to use color unless enabled
        explicitly with some other configuration or the `--color` option.
  
 +column.ui::
 +      Specify whether supported commands should output in columns.
 +      This variable consists of a list of tokens separated by spaces
 +      or commas:
 ++
 +--
 +`always`;;
 +      always show in columns
 +`never`;;
 +      never show in columns
 +`auto`;;
 +      show in columns if the output is to the terminal
 +`column`;;
 +      fill columns before rows (default)
 +`row`;;
 +      fill rows before columns
 +`plain`;;
 +      show in one column
 +`dense`;;
 +      make unequal size columns to utilize more space
 +`nodense`;;
 +      make equal size columns
 +--
 ++
 +This option defaults to 'never'.
 +
 +column.branch::
 +      Specify whether to output branch listing in `git branch` in columns.
 +      See `column.ui` for details.
 +
 +column.status::
 +      Specify whether to output untracked files in `git status` in columns.
 +      See `column.ui` for details.
 +
 +column.tag::
 +      Specify whether to output tag listing in `git tag` in columns.
 +      See `column.ui` for details.
 +
  commit.status::
        A boolean to enable/disable inclusion of status information in the
        commit message template when using an editor to prepare the commit
  
  commit.template::
        Specify a file to use as the template for new commit messages.
 -      "{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
 +      "`~/`" is expanded to the value of `$HOME` and "`~user/`" to the
        specified user's home directory.
  
  credential.helper::
@@@ -1040,7 -958,7 +1043,7 @@@ format.thread:
        a boolean value, or `shallow` or `deep`.  `shallow` threading
        makes every mail a reply to the head of the series,
        where the head is chosen from the cover letter, the
 -      `\--in-reply-to`, and the first patch mail, in this order.
 +      `--in-reply-to`, and the first patch mail, in this order.
        `deep` threading makes every mail a reply to the previous one.
        A true boolean value is the same as `shallow`, and a false
        value disables threading.
@@@ -1471,7 -1389,7 +1474,7 @@@ instaweb.port:
  interactive.singlekey::
        In interactive commands, allow the user to provide one-letter
        input with a single key (i.e., without hitting enter).
 -      Currently this is used by the `\--patch` mode of
 +      Currently this is used by the `--patch` mode of
        linkgit:git-add[1], linkgit:git-checkout[1], linkgit:git-commit[1],
        linkgit:git-reset[1], and linkgit:git-stash[1]. Note that this
        setting is silently ignored if portable keystroke input
  
  log.abbrevCommit::
        If true, makes linkgit:git-log[1], linkgit:git-show[1], and
 -      linkgit:git-whatchanged[1] assume `\--abbrev-commit`. You may
 -      override this option with `\--no-abbrev-commit`.
 +      linkgit:git-whatchanged[1] assume `--abbrev-commit`. You may
 +      override this option with `--no-abbrev-commit`.
  
  log.date::
        Set the default date-time mode for the 'log' command.
        Setting a value for log.date is similar to using 'git log''s
 -      `\--date` option.  Possible values are `relative`, `local`,
 +      `--date` option.  Possible values are `relative`, `local`,
        `default`, `iso`, `rfc`, and `short`; see linkgit:git-log[1]
        for details.
  
@@@ -1675,18 -1593,18 +1678,18 @@@ pack.indexVersion:
        and this config option ignored whenever the corresponding pack is
        larger than 2 GB.
  +
 -If you have an old git that does not understand the version 2 `{asterisk}.idx` file,
 +If you have an old git that does not understand the version 2 `*.idx` file,
  cloning or fetching over a non native protocol (e.g. "http" and "rsync")
 -that will copy both `{asterisk}.pack` file and corresponding `{asterisk}.idx` file from the
 +that will copy both `*.pack` file and corresponding `*.idx` file from the
  other side may give you a repository that cannot be accessed with your
 -older version of git. If the `{asterisk}.pack` file is smaller than 2 GB, however,
 +older version of git. If the `*.pack` file is smaller than 2 GB, however,
  you can use linkgit:git-index-pack[1] on the *.pack file to regenerate
 -the `{asterisk}.idx` file.
 +the `*.idx` file.
  
  pack.packSizeLimit::
        The maximum size of a pack.  This setting only affects
        packing to a file when repacking, i.e. the git:// protocol
 -      is unaffected.  It can be overridden by the `\--max-pack-size`
 +      is unaffected.  It can be overridden by the `--max-pack-size`
        option of linkgit:git-repack[1]. The minimum size allowed is
        limited to 1 MiB. The default is unlimited.
        Common unit suffixes of 'k', 'm', or 'g' are
@@@ -1696,8 -1614,8 +1699,8 @@@ pager.<cmd>:
        If the value is boolean, turns on or off pagination of the
        output of a particular git subcommand when writing to a tty.
        Otherwise, turns on pagination for the subcommand using the
 -      pager specified by the value of `pager.<cmd>`.  If `\--paginate`
 -      or `\--no-pager` is specified on the command line, it takes
 +      pager specified by the value of `pager.<cmd>`.  If `--paginate`
 +      or `--no-pager` is specified on the command line, it takes
        precedence over this option.  To disable pagination for all
        commands, set `core.pager` or `GIT_PAGER` to `cat`.
  
@@@ -1705,9 -1623,9 +1708,9 @@@ pretty.<name>:
        Alias for a --pretty= format string, as specified in
        linkgit:git-log[1]. Any aliases defined here can be used just
        as the built-in pretty formats could. For example,
 -      running `git config pretty.changelog "format:{asterisk} %H %s"`
 +      running `git config pretty.changelog "format:* %H %s"`
        would cause the invocation `git log --pretty=changelog`
 -      to be equivalent to running `git log "--pretty=format:{asterisk} %H %s"`.
 +      to be equivalent to running `git log "--pretty=format:* %H %s"`.
        Note that an alias with the same name as a built-in format
        will be silently ignored.
  
@@@ -1734,33 -1652,13 +1737,33 @@@ push.default:
        no refspec is implied by any of the options given on the command
        line. Possible values are:
  +
 +--
  * `nothing` - do not push anything.
 -* `matching` - push all matching branches.
 -  All branches having the same name in both ends are considered to be
 -  matching. This is the default.
 +* `matching` - push all branches having the same name in both ends.
 +  This is for those who prepare all the branches into a publishable
 +  shape and then push them out with a single command.  It is not
 +  appropriate for pushing into a repository shared by multiple users,
 +  since locally stalled branches will attempt a non-fast forward push
 +  if other users updated the branch.
 +  +
 +  This is currently the default, but Git 2.0 will change the default
 +  to `simple`.
  * `upstream` - push the current branch to its upstream branch.
 -* `tracking` - deprecated synonym for `upstream`.
 +  With this, `git push` will update the same remote ref as the one which
 +  is merged by `git pull`, making `push` and `pull` symmetrical.
 +  See "branch.<name>.merge" for how to configure the upstream branch.
 +* `simple` - like `upstream`, but refuses to push if the upstream
 +  branch's name is different from the local one. This is the safest
 +  option and is well-suited for beginners. It will become the default
 +  in Git 2.0.
  * `current` - push the current branch to a branch of the same name.
 +--
 ++
 +The `simple`, `current` and `upstream` modes are for those who want to
 +push out a single branch after finishing work, even when the other
 +branches are not yet ready to be pushed out. If you are working with
 +other people to push into the same shared repository, you would want
 +to use one of these.
  
  rebase.stat::
        Whether to show a diffstat of what changed upstream since the last
@@@ -1840,7 -1738,7 +1843,7 @@@ remote.<name>.push:
  
  remote.<name>.mirror::
        If true, pushing to this remote will automatically behave
 -      as if the `\--mirror` option was given on the command line.
 +      as if the `--mirror` option was given on the command line.
  
  remote.<name>.skipDefaultUpdate::
        If true, this remote will be skipped by default when updating
diff --combined git-am.sh
index b6a530018e18527efc8ed788e815b380d0206787,f1ae932fa753c7c08769b96420d04fed8ed58804..c02e62d2aa4f3bd2221c687effa3a4ec44918383
+++ b/git-am.sh
@@@ -15,7 -15,6 +15,7 @@@ q,quiet         be quie
  s,signoff       add a Signed-off-by line to the commit message
  u,utf8          recode into utf8 (default)
  k,keep          pass -k flag to git-mailinfo
 +keep-non-patch  pass -b flag to git-mailinfo
  keep-cr         pass --keep-cr flag to git-mailsplit for mbox format
  no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
  c,scissors      strip everything before a scissors line
@@@ -24,7 -23,6 +24,7 @@@ ignore-space-change pass it through git
  ignore-whitespace pass it through git-apply
  directory=      pass it through git-apply
  exclude=        pass it through git-apply
 +include=        pass it through git-apply
  C=              pass it through git-apply
  p=              pass it through git-apply
  patch-format=   format the patch(es) are in
@@@ -139,12 -137,6 +139,12 @@@ fall_back_3way () 
      say Using index info to reconstruct a base tree...
  
      cmd='GIT_INDEX_FILE="$dotest/patch-merge-tmp-index"'
 +
 +    if test -z "$GIT_QUIET"
 +    then
 +      eval "$cmd git diff-index --cached --diff-filter=AM --name-status HEAD"
 +    fi
 +
      cmd="$cmd git apply --cached $git_apply_opt"' <"$dotest/patch"'
      if eval "$cmd"
      then
@@@ -260,7 -252,7 +260,7 @@@ check_patch_format () 
  split_patches () {
        case "$patch_format" in
        mbox)
 -              if test -n "$rebasing" || test t = "$keepcr"
 +              if test t = "$keepcr"
                then
                    keep_cr=--keep-cr
                else
@@@ -387,9 -379,7 +387,9 @@@ d
        -i|--interactive)
                interactive=t ;;
        -b|--binary)
 -              : ;;
 +              echo >&2 "The $1 option has been a no-op for long time, and"
 +              echo >&2 "it will be removed. Please do not use it anymore."
 +              ;;
        -3|--3way)
                threeway=t ;;
        -s|--signoff)
                utf8= ;;
        -k|--keep)
                keep=t ;;
 +      --keep-non-patch)
 +              keep=b ;;
        -c|--scissors)
                scissors=t ;;
        --no-scissors)
        --abort)
                abort=t ;;
        --rebasing)
 -              rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
 +              rebasing=t threeway=t ;;
        -d|--dotest)
                die "$(gettext "-d option is no longer supported.  Do not use.")"
                ;;
        --resolvemsg)
                shift; resolvemsg=$1 ;;
 -      --whitespace|--directory|--exclude)
 +      --whitespace|--directory|--exclude|--include)
                git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
        -C|-p)
                git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
@@@ -580,25 -568,16 +580,25 @@@ case "$resolved" i
        fi
  esac
  
 +# Now, decide what command line options we will give to the git
 +# commands we invoke, based on the result of parsing command line
 +# options and previous invocation state stored in $dotest/ files.
 +
  if test "$(cat "$dotest/utf8")" = t
  then
        utf8=-u
  else
        utf8=-n
  fi
 -if test "$(cat "$dotest/keep")" = t
 -then
 -      keep=-k
 -fi
 +keep=$(cat "$dotest/keep")
 +case "$keep" in
 +t)
 +      keep=-k ;;
 +b)
 +      keep=-b ;;
 +*)
 +      keep= ;;
 +esac
  case "$(cat "$dotest/scissors")" in
  t)
        scissors=--scissors ;;
        # by the user, or the user can tell us to do so by --resolved flag.
        case "$resume" in
        '')
 -              git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
 -                      <"$dotest/$msgnum" >"$dotest/info" ||
 -                      stop_here $this
 -
 -              # skip pine's internal folder data
 -              sane_grep '^Author: Mail System Internal Data$' \
 -                      <"$dotest"/info >/dev/null &&
 -                      go_next && continue
 -
 -              test -s "$dotest/patch" || {
 -                      eval_gettextln "Patch is empty.  Was it split wrong?
 -If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
 -To restore the original branch and stop patching run \"\$cmdline --abort\"."
 -                      stop_here $this
 -              }
 -              rm -f "$dotest/original-commit" "$dotest/author-script"
 -              if test -f "$dotest/rebasing" &&
 +              if test -f "$dotest/rebasing"
 +              then
                        commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
                                -e q "$dotest/$msgnum") &&
 -                      test "$(git cat-file -t "$commit")" = commit
 -              then
 +                      test "$(git cat-file -t "$commit")" = commit ||
 +                              stop_here $this
                        git cat-file commit "$commit" |
                        sed -e '1,/^$/d' >"$dotest/msg-clean"
 -                      echo "$commit" > "$dotest/original-commit"
 -                      get_author_ident_from_commit "$commit" > "$dotest/author-script"
 +                      echo "$commit" >"$dotest/original-commit"
 +                      get_author_ident_from_commit "$commit" >"$dotest/author-script"
 +                      git diff-tree --root --binary "$commit" >"$dotest/patch"
                else
 +                      git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
 +                              <"$dotest/$msgnum" >"$dotest/info" ||
 +                              stop_here $this
 +
 +                      # skip pine's internal folder data
 +                      sane_grep '^Author: Mail System Internal Data$' \
 +                              <"$dotest"/info >/dev/null &&
 +                              go_next && continue
 +
 +                      test -s "$dotest/patch" || {
 +                              eval_gettextln "Patch is empty.  Was it split wrong?
 +If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
 +To restore the original branch and stop patching run \"\$cmdline --abort\"."
 +                              stop_here $this
 +                      }
 +                      rm -f "$dotest/original-commit" "$dotest/author-script"
                        {
                                sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
                                echo
@@@ -857,6 -834,11 +857,11 @@@ did you forget to use 'git add'?
        if test $apply_status != 0
        then
                eval_gettextln 'Patch failed at $msgnum $FIRSTLINE'
+               if test "$(git config --bool advice.amworkdir)" != false
+               then
+                       eval_gettextln "The copy of the patch that failed is found in:
+    $dotest/patch"
+               fi
                stop_here_user_resolve $this
        fi