Code

Do not over-quote the -f envelopesender value.
[git.git] / git-am.sh
index 8b5712968ebcfe3f8fb5426e5104de2e7d2d3334..b66173c0cd8e7908c1ac9ffc9c9a6a91160849a0 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -2,8 +2,10 @@
 #
 # Copyright (c) 2005, 2006 Junio C Hamano
 
-USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
-  [--interactive] [--whitespace=<option>] [-C<n>] [-p<n>] <mbox>...
+USAGE='[--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8]
+  [--3way] [--interactive] [--binary]
+  [--whitespace=<option>] [-C<n>] [-p<n>]
+  <mbox>|<Maildir>...
   or, when resuming [--skip | --resolved]'
 . git-sh-setup
 set_reflog_action am
@@ -60,17 +62,17 @@ fall_back_3way () {
     mkdir "$dotest/patch-merge-tmp-dir"
 
     # First see if the patch records the index info that we can use.
-    git-apply -z --index-info "$dotest/patch" \
+    git apply -z --index-info "$dotest/patch" \
        >"$dotest/patch-merge-index-info" &&
     GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
-    git-update-index -z --index-info <"$dotest/patch-merge-index-info" &&
+    git update-index -z --index-info <"$dotest/patch-merge-index-info" &&
     GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
-    git-write-tree >"$dotest/patch-merge-base+" ||
+    git write-tree >"$dotest/patch-merge-base+" ||
     cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
 
     echo Using index info to reconstruct a base tree...
     if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
-       git-apply $binary --cached <"$dotest/patch"
+       git apply $binary --cached <"$dotest/patch"
     then
        mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
        mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
@@ -80,7 +82,7 @@ It does not apply to blobs recorded in its index."
     fi
 
     test -f "$dotest/patch-merge-index" &&
-    his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git-write-tree) &&
+    his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git write-tree) &&
     orig_tree=$(cat "$dotest/patch-merge-base") &&
     rm -fr "$dotest"/patch-merge-* || exit 1
 
@@ -95,10 +97,7 @@ It does not apply to blobs recorded in its index."
     eval GITHEAD_$his_tree='"$SUBJECT"'
     export GITHEAD_$his_tree
     git-merge-recursive $orig_tree -- HEAD $his_tree || {
-           if test -d "$GIT_DIR/rr-cache"
-           then
-               git-rerere
-           fi
+           git rerere
            echo Failed to merge in the changes.
            exit 1
     }
@@ -106,10 +105,11 @@ It does not apply to blobs recorded in its index."
 }
 
 prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary=
+resolvemsg= resume=
 git_apply_opt=
 
-while case "$#" in 0) break;; esac
+while test $# != 0
 do
        case "$1" in
        -d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*)
@@ -198,7 +198,7 @@ else
        # Start afresh.
        mkdir -p "$dotest" || exit
 
-       git-mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||  {
+       git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||  {
                rm -fr "$dotest"
                exit 1
        }
@@ -216,7 +216,7 @@ fi
 
 case "$resolved" in
 '')
-       files=$(git-diff-index --cached --name-only HEAD) || exit
+       files=$(git diff-index --cached --name-only HEAD) || exit
        if [ "$files" ]; then
           echo "Dirty index: cannot apply patches (dirty: $files)" >&2
           exit 1
@@ -252,10 +252,7 @@ last=`cat "$dotest/last"`
 this=`cat "$dotest/next"`
 if test "$skip" = t
 then
-       if test -d "$GIT_DIR/rr-cache"
-       then
-               git-rerere clear
-       fi
+       git rerere clear
        this=`expr "$this" + 1`
        resume=
 fi
@@ -287,14 +284,20 @@ do
        # 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 $utf8 "$dotest/msg" "$dotest/patch" \
                        <"$dotest/$msgnum" >"$dotest/info" ||
                        stop_here $this
+
+               # skip pine's internal folder data
+               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?"
                        stop_here $this
                }
-               git-stripspace < "$dotest/msg" > "$dotest/msg-clean"
+               git stripspace < "$dotest/msg" > "$dotest/msg-clean"
                ;;
        esac
 
@@ -347,7 +350,7 @@ do
                case "$resolved$interactive" in
                tt)
                        # This is used only for interactive view option.
-                       git-diff-index -p --cached HEAD >"$dotest/patch"
+                       git diff-index -p --cached HEAD >"$dotest/patch"
                        ;;
                esac
        esac
@@ -370,7 +373,7 @@ do
                [yY]*) action=yes ;;
                [aA]*) action=yes interactive= ;;
                [nN]*) action=skip ;;
-               [eE]*) "${VISUAL:-${EDITOR:-vi}}" "$dotest/final-commit"
+               [eE]*) git_editor "$dotest/final-commit"
                       action=again ;;
                [vV]*) action=again
                       LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -399,7 +402,7 @@ do
 
        case "$resolved" in
        '')
-               git-apply $git_apply_opt $binary --index "$dotest/patch"
+               git apply $git_apply_opt $binary --index "$dotest/patch"
                apply_status=$?
                ;;
        t)
@@ -408,11 +411,11 @@ do
                # trust what the user has in the index file and the
                # working tree.
                resolved=
-               git-diff-index --quiet --cached HEAD && {
+               git diff-index --quiet --cached HEAD && {
                        echo "No changes - did you forget to use 'git add'?"
                        stop_here_user_resolve $this
                }
-               unmerged=$(git-ls-files -u)
+               unmerged=$(git ls-files -u)
                if test -n "$unmerged"
                then
                        echo "You still have unmerged paths in your index"
@@ -420,10 +423,7 @@ do
                        stop_here_user_resolve $this
                fi
                apply_status=0
-               if test -d "$GIT_DIR/rr-cache"
-               then
-                       git rerere
-               fi
+               git rerere
                ;;
        esac
 
@@ -433,7 +433,7 @@ do
                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 && {
+                   git diff-index --quiet --cached HEAD && {
                        echo No changes -- Patch already applied.
                        go_next
                        continue
@@ -453,12 +453,12 @@ do
                "$GIT_DIR"/hooks/pre-applypatch || stop_here $this
        fi
 
-       tree=$(git-write-tree) &&
+       tree=$(git write-tree) &&
        echo Wrote tree $tree &&
-       parent=$(git-rev-parse --verify HEAD) &&
-       commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") &&
+       parent=$(git rev-parse --verify HEAD) &&
+       commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
        echo Committed: $commit &&
-       git-update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
+       git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
        stop_here $this
 
        if test -x "$GIT_DIR"/hooks/post-applypatch