Code

Merge branch 'gb/maint-am-patch-format-error-message'
authorJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2011 20:18:07 +0000 (13:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2011 20:18:07 +0000 (13:18 -0700)
* gb/maint-am-patch-format-error-message:
  am: format is in $patch_format, not parse_patch

Conflicts:
git-am.sh

1  2 
Documentation/RelNotes/1.7.7.txt
git-am.sh

index 82dc9292c3503ecdddd9b9cf6274eae110197188,0000000000000000000000000000000000000000..6b3264aa7ec42b41c4e42edd7fef0d45e352271b
mode 100644,000000..100644
--- /dev/null
@@@ -1,146 -1,0 +1,159 @@@
 +Git v1.7.7 Release Notes
 +========================
 +
 +Updates since v1.7.6
 +--------------------
 +
 + * The scripting part of the codebase is getting prepared for i18n/l10n.
 +
 + * Interix, Cygwin and Minix ports got updated.
 +
 + * Various updates git-p4 (in contrib/) and "git fast-import".
 +
 + * Gitweb learned to read from /etc/gitweb-common.conf when it exists,
 +   before reading from gitweb_config.perl or from /etc/gitweb.conf
 +   (this last one is read only when per-repository gitweb_config.perl
 +   does not exist).
 +
 + * Various codepaths that invoked zlib deflate/inflate assumed that these
 +   functions can compress or uncompress more than 4GB data in one call on
 +   platforms with 64-bit long, which has been corrected.
 +
 + * Git now recognizes loose objects written by other implementations that
 +   uses non-standard window size for zlib deflation (e.g. Agit running on
 +   Android with 4kb window). We used to reject anything that was not
 +   deflated with 32kb window.
 +
 + * Interaction between the use of pager and coloring of the output has
 +   been improved, especially when a command that is not built-in was
 +   involved.
 +
 + * "git am" learned to pass "--exclude=<path>" option through to underlying
 +   "git apply".
 +
 + * You can now feed many empty lines before feeding a mbox file to
 +   "git am".
 +
 + * "git archive" can be told to pass the output to gzip compression and
 +   produce "archive.tar.gz".
 +
 + * "git bisect" can be used in a bare repository (provided if the test
 +   you perform per each iteration does not need a working tree, of
 +   course).
 +
 + * The length of abbreviated object names in "git branch -v" output
 +   now honors core.abbrev configuration variable.
 +
 + * "git check-attr" can take relative paths from the command line.
 +
 + * "git check-attr" learned "--all" option to list the attributes for a
 +   given path.
 +
 + * "git checkout" (both the code to update the files upon checking out a
 +   different branch, the code to checkout specific set of files) learned
 +   to stream the data from object store when possible, without having to
 +   read the entire contents of a file in memory first. An earlier round
 +   of this code that is not in any released version had a large leak but
 +   now it has been plugged.
 +
 + * "git clone" can now take "--config key=value" option to set the
 +   repository configuration options that affect the initial checkout.
 +
 + * "git commit <paths>..." now lets you feed relative pathspecs that
 +   refer outside your current subdirectory.
 +
 + * "git diff --stat" learned --stat-count option to limit the output of
 +   diffstat report.
 +
 + * "git diff" learned "--histogram" option, to use a different diff
 +   generation machinery stolen from jgit, which might give better
 +   performance.
 +
++ * "git diff" had a wierd worst case behaviour that can be triggered
++   when comparing files with potentially many places that could match.
++
 + * "git fetch", "git push" and friends no longer show connection
 +   errors for addresses that couldn't be connected when at least one
 +   address succeeds (this is arguably a regression but a deliberate
 +   one).
 +
 + * "git grep" learned --break and --heading options, to let users mimic
 +   output format of "ack".
 +
 + * "git grep" learned "-W" option that shows wider context using the same
 +   logic used by "git diff" to determine the hunk header.
 +
 + * The "--decorate" option to "git log" and its family learned to
 +   highlight grafted and replaced commits.
 +
 + * "git rebase master topci" no longer spews usage hints after giving
 +   "fatal: no such branch: topci" error message.
 +
++ * The recursive merge strategy implementation got a fairly large
++   fixes for many corner cases that may rarely happen in real world
++   projects (it has been verified that none of the 16000+ merges in
++   the Linux kernel history back to v2.6.12 is affected with the
++   corner case bugs this update fixes).
++
 + * "git stash" learned --include-untracked option.
 +
 + * "git submodule update" used to stop at the first error updating a
 +   submodule; it now goes on to update other submodules that can be
 +   updated, and reports the ones with errors at the end.
 +
++ * "git push" can be told with --recurse-submodules=check option to
++   refuse pushing of the supermodule, if any of its submodules'
++   commits hasn't been pushed out to their remotes.
++
 + * "git upload-pack" and "git receive-pack" learned to pretend only a
 +   subset of the refs exist in a repository. This may help a site to
 +   put many tiny repositories into one repository (this would not be
 +   useful for larger repositories as repacking would be problematic).
 +
 + * "git verify-pack" has been rewritten to use the "index-pack" machinery
 +   that is more efficient in reading objects in packfiles.
 +
 + * test scripts for gitweb tried to run even when CGI-related perl modules
 +   are not installed; it now exits early when they are unavailable.
 +
 +Also contains various documentation updates and minor miscellaneous
 +changes.
 +
 +
 +Fixes since v1.7.6
 +------------------
 +
 +Unless otherwise noted, all the fixes in 1.7.6.X maintenance track are
 +included in this release.
 +
 + * "git branch --set-upstream @{-1} foo" did not expand @{-1} correctly.
 +   (merge e9d4f74 mg/branch-set-upstream-previous later to 'maint').
 +
 + * "git branch -m" and "git checkout -b" incorrectly allowed the tip
 +   of the branch that is currently checked out updated.
 +   (merge 55c4a67 ci/forbid-unwanted-current-branch-update later to 'maint').
 +
 + * "git clone" failed to clone locally from a ".git" file that itself
 +   is not a directory but is a pointer to one.
 +   (merge 9b0ebc7 nd/maint-clone-gitdir later to 'maint').
 +
 + * "git clone" from a local repository that borrows from another
 +   object store using a relative path in its objects/info/alternates
 +   file did not adjust the alternates in the resulting repository.
 +   (merge e6baf4a1 jc/maint-clone-alternates later to 'maint').
 +
 + * "git describe --dirty" did not refresh the index before checking the
 +   state of the working tree files.
 +   (cherry-pick bb57148 ac/describe-dirty-refresh later to 'maint').
 +
 + * "git ls-files ../$path" that is run from a subdirectory reported errors
 +   incorrectly when there is no such path that matches the given pathspec.
 +   (merge 0f64bfa cb/maint-ls-files-error-report later to 'maint').
 +
 +--
 +exec >/var/tmp/1
 +echo O=$(git describe master)
 +O=v1.7.6.1-415-g284daf2
 +git log --first-parent --oneline $O..master
 +echo
 +git shortlog --no-merges ^maint ^$O master
diff --combined git-am.sh
index e78cb547b7875ba68ddedbc507b7b0d7d0a50b31,78e3ee039f921a0ae5d121340153fee93ab45154..745fda9cbde1193975392b74374227a3655f0ac0
+++ b/git-am.sh
@@@ -5,7 -5,7 +5,7 @@@
  SUBDIRECTORY_OK=Yes
  OPTIONS_KEEPDASHDASH=
  OPTIONS_SPEC="\
 -git am [options] [<mbox>|<Maildir>...]
 +git am [options] [(<mbox>|<Maildir>)...]
  git am [options] (--resolved | --skip | --abort)
  --
  i,interactive   run interactively
@@@ -15,37 -15,28 +15,37 @@@ 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-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
  whitespace=     pass it through git-apply
 +ignore-space-change pass it through git-apply
 +ignore-whitespace pass it through git-apply
  directory=      pass it through git-apply
 +exclude=        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
  reject          pass it through git-apply
  resolvemsg=     override error message when patch failure occurs
 -r,resolved      to be used after a patch failure
 +continue        continue applying patches after resolving a conflict
 +r,resolved      synonyms for --continue
  skip            skip the current patch
  abort           restore the original branch and abort the patching operation.
  committer-date-is-author-date    lie about committer date
  ignore-date     use current timestamp for author date
 +rerere-autoupdate update the index with reused conflict resolution if possible
  rebasing*       (internal use for git-rebase)"
  
  . git-sh-setup
 +. git-sh-i18n
  prefix=$(git rev-parse --show-prefix)
  set_reflog_action am
  require_work_tree
  cd_to_toplevel
  
  git var GIT_COMMITTER_IDENT >/dev/null ||
 -      die "You need to set your committer info first"
 +      die "$(gettext "You need to set your committer info first")"
  
  if git rev-parse --verify -q HEAD >/dev/null
  then
@@@ -54,55 -45,32 +54,55 @@@ els
        HAS_HEAD=
  fi
  
 +cmdline="git am"
 +if test '' != "$interactive"
 +then
 +      cmdline="$cmdline -i"
 +fi
 +if test '' != "$threeway"
 +then
 +      cmdline="$cmdline -3"
 +fi
 +
  sq () {
        git rev-parse --sq-quote "$@"
  }
  
  stop_here () {
      echo "$1" >"$dotest/next"
 +    git rev-parse --verify -q HEAD >"$dotest/abort-safety"
      exit 1
  }
  
 +safe_to_abort () {
 +      if test -f "$dotest/dirtyindex"
 +      then
 +              return 1
 +      fi
 +
 +      if ! test -s "$dotest/abort-safety"
 +      then
 +              return 0
 +      fi
 +
 +      abort_safety=$(cat "$dotest/abort-safety")
 +      if test "z$(git rev-parse --verify -q HEAD)" = "z$abort_safety"
 +      then
 +              return 0
 +      fi
 +              gettextln "You seem to have moved HEAD since the last 'am' failure.
 +Not rewinding to ORIG_HEAD" >&2
 +      return 1
 +}
 +
  stop_here_user_resolve () {
      if [ -n "$resolvemsg" ]; then
            printf '%s\n' "$resolvemsg"
            stop_here $1
      fi
 -    cmdline="git am"
 -    if test '' != "$interactive"
 -    then
 -        cmdline="$cmdline -i"
 -    fi
 -    if test '' != "$threeway"
 -    then
 -        cmdline="$cmdline -3"
 -    fi
 -    echo "When you have resolved this problem run \"$cmdline --resolved\"."
 -    echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
 -    echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
 +    eval_gettextln "When you have resolved this problem run \"\$cmdline --resolved\".
 +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 $1
  }
@@@ -116,7 -84,7 +116,7 @@@ go_next () 
  
  cannot_fallback () {
        echo "$1"
 -      echo "Cannot fall back to three-way merge."
 +      gettextln "Cannot fall back to three-way merge."
        exit 1
  }
  
@@@ -131,7 -99,7 +131,7 @@@ fall_back_3way () 
        "$dotest/patch" &&
      GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
      git write-tree >"$dotest/patch-merge-base+" ||
 -    cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
 +    cannot_fallback "$(gettext "Repository lacks necessary blobs to fall back on 3-way merge.")"
  
      say Using index info to reconstruct a base tree...
      if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
        mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
        mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
      else
 -        cannot_fallback "Did you hand edit your patch?
 -It does not apply to blobs recorded in its index."
 +      cannot_fallback "$(gettext "Did you hand edit your patch?
 +It does not apply to blobs recorded in its index.")"
      fi
  
      test -f "$dotest/patch-merge-index" &&
      orig_tree=$(cat "$dotest/patch-merge-base") &&
      rm -fr "$dotest"/patch-merge-* || exit 1
  
 -    say Falling back to patching base and 3-way merge...
 +    say "$(gettext "Falling back to patching base and 3-way merge...")"
  
      # This is not so wrong.  Depending on which base we picked,
      # orig_tree may be wildly different from ours, but his_tree
      export GITHEAD_$his_tree
      if test -n "$GIT_QUIET"
      then
 -          export GIT_MERGE_VERBOSITY=0
 +          GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY
      fi
      git-merge-recursive $orig_tree -- HEAD $his_tree || {
 -          git rerere
 +          git rerere $allow_rerere_autoupdate
            echo Failed to merge in the changes.
            exit 1
      }
@@@ -194,15 -162,10 +194,15 @@@ check_patch_format () 
                return 0
        fi
  
 -      # otherwise, check the first few lines of the first patch to try
 -      # to detect its format
 +      # otherwise, check the first few non-blank lines of the first
 +      # patch to try to detect its format
        {
 -              read l1
 +              # Start from first line containing non-whitespace
 +              l1=
 +              while test -z "$l1"
 +              do
 +                      read l1
 +              done
                read l2
                read l3
                case "$l1" in
                        # discarding the indented remainder of folded lines,
                        # and see if it looks like that they all begin with the
                        # header field names...
 -                      sed -n -e '/^$/q' -e '/^[       ]/d' -e p "$1" |
 -                      egrep -v '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
 +                      tr -d '\015' <"$1" |
 +                      sed -n -e '/^$/q' -e '/^[       ]/d' -e p |
 +                      sane_egrep -v '^[!-9;-~]+:' >/dev/null ||
                        patch_format=mbox
                fi
        } < "$1" || clean_abort
  split_patches () {
        case "$patch_format" in
        mbox)
 -              git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||
 +              if test -n "$rebasing" || test t = "$keepcr"
 +              then
 +                  keep_cr=--keep-cr
 +              else
 +                  keep_cr=
 +              fi
 +              git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
                clean_abort
                ;;
        stgit-series)
                if test $# -ne 1
                then
 -                      clean_abort "Only one StGIT patch series can be applied at once"
 +                      clean_abort "$(gettext "Only one StGIT patch series can be applied at once")"
                fi
                series_dir=`dirname "$1"`
                series_file="$1"
                msgnum=
                ;;
        *)
-               if test -n "$parse_patch" ; then
+               if test -n "$patch_format"
+               then
 -                      clean_abort "Patch format $patch_format is not supported."
 +                      clean_abort "$(eval_gettext "Patch format \$patch_format is not supported.")"
                else
 -                      clean_abort "Patch format detection failed."
 +                      clean_abort "$(gettext "Patch format detection failed.")"
                fi
                ;;
        esac
  
  prec=4
  dotest="$GIT_DIR/rebase-apply"
 -sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
 -resolvemsg= resume=
 +sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
 +resolvemsg= resume= scissors= no_inbody_headers=
  git_apply_opt=
  committer_date_is_author_date=
  ignore_date=
 +allow_rerere_autoupdate=
 +
 +if test "$(git config --bool --get am.keepcr)" = true
 +then
 +    keepcr=t
 +fi
  
  while test $# != 0
  do
                utf8= ;;
        -k|--keep)
                keep=t ;;
 -      -r|--resolved)
 +      -c|--scissors)
 +              scissors=t ;;
 +      --no-scissors)
 +              scissors=f ;;
 +      -r|--resolved|--continue)
                resolved=t ;;
        --skip)
                skip=t ;;
        --abort)
                abort=t ;;
        --rebasing)
 -              rebasing=t threeway=t keep=t ;;
 +              rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
        -d|--dotest)
 -              die "-d option is no longer supported.  Do not use."
 +              die "$(gettext "-d option is no longer supported.  Do not use.")"
                ;;
        --resolvemsg)
                shift; resolvemsg=$1 ;;
 -      --whitespace|--directory)
 +      --whitespace|--directory|--exclude)
                git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
        -C|-p)
                git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
        --patch-format)
                shift ; patch_format="$1" ;;
 -      --reject)
 +      --reject|--ignore-whitespace|--ignore-space-change)
                git_apply_opt="$git_apply_opt $1" ;;
        --committer-date-is-author-date)
                committer_date_is_author_date=t ;;
        --ignore-date)
                ignore_date=t ;;
 +      --rerere-autoupdate|--no-rerere-autoupdate)
 +              allow_rerere_autoupdate="$1" ;;
        -q|--quiet)
                GIT_QUIET=t ;;
 +      --keep-cr)
 +              keepcr=t ;;
 +      --no-keep-cr)
 +              keepcr=f ;;
        --)
                shift; break ;;
        *)
@@@ -428,12 -369,12 +429,12 @@@ the
                false
                ;;
        esac ||
 -      die "previous rebase directory $dotest still exists but mbox given."
 +      die "$(eval_gettext "previous rebase directory \$dotest still exists but mbox given.")"
        resume=yes
  
        case "$skip,$abort" in
        t,t)
 -              die "Please make up your mind. --skip or --abort?"
 +              die "$(gettext "Please make up your mind. --skip or --abort?")"
                ;;
        t,)
                git rerere clear
                        exec git rebase --abort
                fi
                git rerere clear
 -              test -f "$dotest/dirtyindex" || {
 +              if safe_to_abort
 +              then
                        git read-tree --reset -u HEAD ORIG_HEAD
                        git reset ORIG_HEAD
 -              }
 +              fi
                rm -fr "$dotest"
                exit ;;
        esac
  else
        # Make sure we are not given --skip, --resolved, nor --abort
        test "$skip$resolved$abort" = "" ||
 -              die "Resolve operation not in progress, we are not resuming."
 +              die "$(gettext "Resolve operation not in progress, we are not resuming.")"
  
        # Start afresh.
        mkdir -p "$dotest" || exit
                                set x
                                first=
                        }
 -                      case "$arg" in
 -                      /*)
 -                              set "$@" "$arg" ;;
 -                      *)
 -                              set "$@" "$prefix$arg" ;;
 -                      esac
 +                      if is_absolute_path "$arg"
 +                      then
 +                              set "$@" "$arg"
 +                      else
 +                              set "$@" "$prefix$arg"
 +                      fi
                done
                shift
        fi
  
        split_patches "$@"
  
 -      # -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept
 -      # for the resuming session after a patch failure.
 -      # -i can and must be given when resuming.
 +      # -i can and must be given when resuming; everything
 +      # else is kept
        echo " $git_apply_opt" >"$dotest/apply-opt"
        echo "$threeway" >"$dotest/threeway"
        echo "$sign" >"$dotest/sign"
        echo "$utf8" >"$dotest/utf8"
        echo "$keep" >"$dotest/keep"
 +      echo "$keepcr" >"$dotest/keepcr"
 +      echo "$scissors" >"$dotest/scissors"
 +      echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
        echo "$GIT_QUIET" >"$dotest/quiet"
        echo 1 >"$dotest/next"
        if test -n "$rebasing"
        fi
  fi
  
 +git update-index -q --refresh
 +
  case "$resolved" in
  '')
        case "$HAS_HEAD" in
        if test "$files"
        then
                test -n "$HAS_HEAD" && : >"$dotest/dirtyindex"
 -              die "Dirty index: cannot apply patches (dirty: $files)"
 +              die "$(eval_gettext "Dirty index: cannot apply patches (dirty: \$files)")"
        fi
  esac
  
@@@ -541,24 -477,6 +542,24 @@@ if test "$(cat "$dotest/keep")" = 
  then
        keep=-k
  fi
 +case "$(cat "$dotest/keepcr")" in
 +t)
 +      keepcr=--keep-cr ;;
 +f)
 +      keepcr=--no-keep-cr ;;
 +esac
 +case "$(cat "$dotest/scissors")" in
 +t)
 +      scissors=--scissors ;;
 +f)
 +      scissors=--no-scissors ;;
 +esac
 +if test "$(cat "$dotest/no_inbody_headers")" = t
 +then
 +      no_inbody_headers=--no-inbody-headers
 +else
 +      no_inbody_headers=
 +fi
  if test "$(cat "$dotest/quiet")" = t
  then
        GIT_QUIET=t
@@@ -586,6 -504,13 +587,6 @@@ the
        resume=
  fi
  
 -if test "$this" -gt "$last"
 -then
 -      say Nothing to do.
 -      rm -fr "$dotest"
 -      exit
 -fi
 -
  while test "$this" -le "$last"
  do
        msgnum=`printf "%0${prec}d" $this`
        # by the user, or the user can tell us to do so by --resolved flag.
        case "$resume" in
        '')
 -              git mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \
 +              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
 -              grep '^Author: Mail System Internal Data$' \
 +              sane_grep '^Author: Mail System Internal Data$' \
                        <"$dotest"/info >/dev/null &&
                        go_next && continue
  
                test -s "$dotest/patch" || {
 -                      echo "Patch is empty.  Was it split wrong?"
 +                      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" &&
                        commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
                                -e q "$dotest/$msgnum") &&
                then
                        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"
                else
 -                      SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
 -                      case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
 -
 -                      (printf '%s\n\n' "$SUBJECT"; cat "$dotest/msg") |
 -                              git stripspace > "$dotest/msg-clean"
 +                      {
 +                              sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
 +                              echo
 +                              cat "$dotest/msg"
 +                      } |
 +                      git stripspace > "$dotest/msg-clean"
                fi
                ;;
        esac
  
 -      GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
 -      GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
 -      GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
 +      if test -f "$dotest/author-script"
 +      then
 +              eval $(cat "$dotest/author-script")
 +      else
 +              GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
 +              GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
 +              GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
 +      fi
  
        if test -z "$GIT_AUTHOR_EMAIL"
        then
 -              echo "Patch does not have a valid e-mail address."
 +              gettextln "Patch does not have a valid e-mail address."
                stop_here $this
        fi
  
        if test "$interactive" = t
        then
            test -t 0 ||
 -          die "cannot be interactive without stdin connected to a terminal."
 +          die "$(gettext "cannot be interactive without stdin connected to a terminal.")"
            action=again
            while test "$action" = again
            do
 -              echo "Commit Body is:"
 +              gettextln "Commit Body is:"
                echo "--------------------------"
                cat "$dotest/final-commit"
                echo "--------------------------"
 -              printf "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
 +              # TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a]
 +              # in your translation. The program will only accept English
 +              # input at this point.
 +              gettext "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
                read reply
                case "$reply" in
                [yY]*) action=yes ;;
                [eE]*) git_editor "$dotest/final-commit"
                       action=again ;;
                [vV]*) action=again
 -                     LESS=-S ${PAGER:-less} "$dotest/patch" ;;
 +                     git_pager "$dotest/patch" ;;
                *)     action=again ;;
                esac
            done
        else
            action=yes
        fi
 -      FIRSTLINE=$(sed 1q "$dotest/final-commit")
 +
 +      if test -f "$dotest/final-commit"
 +      then
 +              FIRSTLINE=$(sed 1q "$dotest/final-commit")
 +      else
 +              FIRSTLINE=""
 +      fi
  
        if test $action = skip
        then
                stop_here $this
        fi
  
 -      say "Applying: $FIRSTLINE"
 +      say "$(eval_gettext "Applying: \$FIRSTLINE")"
  
        case "$resolved" in
        '')
                # working tree.
                resolved=
                git diff-index --quiet --cached HEAD -- && {
 -                      echo "No changes - did you forget to use 'git add'?"
 +                      gettextln "No changes - did you forget to use 'git add'?
 +If there is nothing left to stage, chances are that something else
 +already introduced the same changes; you might want to skip this patch."
                        stop_here_user_resolve $this
                }
                unmerged=$(git ls-files -u)
                if test -n "$unmerged"
                then
 -                      echo "You still have unmerged paths in your index"
 -                      echo "did you forget to use 'git add'?"
 +                      gettextln "You still have unmerged paths in your index
 +did you forget to use 'git add'?"
                        stop_here_user_resolve $this
                fi
                apply_status=0
                ;;
        esac
  
 -      if test $apply_status = 1 && test "$threeway" = t
 +      if test $apply_status != 0 && test "$threeway" = t
        then
                if (fall_back_3way)
                then
                    # Applying the patch to an earlier tree and merging the
                    # result may have produced the same tree as ours.
                    git diff-index --quiet --cached HEAD -- && {
 -                      say No changes -- Patch already applied.
 +                      say "$(gettext "No changes -- Patch already applied.")"
                        go_next
                        continue
                    }
        fi
        if test $apply_status != 0
        then
 -              printf 'Patch failed at %s %s\n' "$msgnum" "$FIRSTLINE"
 +              eval_gettextln 'Patch failed at $msgnum $FIRSTLINE'
                stop_here_user_resolve $this
        fi
  
                        GIT_AUTHOR_DATE=
                fi
                parent=$(git rev-parse --verify -q HEAD) ||
 -              say >&2 "applying to an empty history"
 +              say >&2 "$(gettext "applying to an empty history")"
  
                if test -n "$committer_date_is_author_date"
                then
        git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
        stop_here $this
  
 +      if test -f "$dotest/original-commit"; then
 +              echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
 +      fi
 +
        if test -x "$GIT_DIR"/hooks/post-applypatch
        then
                "$GIT_DIR"/hooks/post-applypatch
        go_next
  done
  
 -git gc --auto
 +if test -s "$dotest"/rewritten; then
 +    git notes copy --for-rewrite=rebase < "$dotest"/rewritten
 +    if test -x "$GIT_DIR"/hooks/post-rewrite; then
 +      "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
 +    fi
 +fi
  
  rm -fr "$dotest"
 +git gc --auto