#
# 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
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"
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
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
}
}
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=*)
# 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
}
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
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
# 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
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
[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" ;;
case "$resolved" in
'')
- git-apply $git_apply_opt $binary --index "$dotest/patch"
+ git apply $git_apply_opt $binary --index "$dotest/patch"
apply_status=$?
;;
t)
# 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"
stop_here_user_resolve $this
fi
apply_status=0
- if test -d "$GIT_DIR/rr-cache"
- then
- git rerere
- fi
+ git rerere
;;
esac
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
"$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