git-am foreign patch support: introduce patch_format
Set up a framework to allow git-am to support patches which are not in mailbox format. Introduce a patch_format variable that presently can only be set from the command line, defaulting to 'mbox' (the only supported format) if not specified. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
33fd7169ed
commit
a5a6755a1d
37
git-am.sh
37
git-am.sh
@ -18,6 +18,7 @@ whitespace= pass it through git-apply
|
|||||||
directory= pass it through git-apply
|
directory= pass it through git-apply
|
||||||
C= pass it through git-apply
|
C= pass it through git-apply
|
||||||
p= 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
|
reject pass it through git-apply
|
||||||
resolvemsg= override error message when patch failure occurs
|
resolvemsg= override error message when patch failure occurs
|
||||||
r,resolved to be used after a patch failure
|
r,resolved to be used after a patch failure
|
||||||
@ -133,6 +134,32 @@ It does not apply to blobs recorded in its index."
|
|||||||
unset GITHEAD_$his_tree
|
unset GITHEAD_$his_tree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch_format=
|
||||||
|
|
||||||
|
check_patch_format () {
|
||||||
|
# early return if patch_format was set from the command line
|
||||||
|
if test -n "$patch_format"
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
patch_format=mbox
|
||||||
|
}
|
||||||
|
|
||||||
|
split_patches () {
|
||||||
|
case "$patch_format" in
|
||||||
|
mbox)
|
||||||
|
git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
|
||||||
|
rm -fr "$dotest"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Patch format $patch_format is not supported."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
prec=4
|
prec=4
|
||||||
dotest="$GIT_DIR/rebase-apply"
|
dotest="$GIT_DIR/rebase-apply"
|
||||||
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
|
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
|
||||||
@ -175,6 +202,8 @@ do
|
|||||||
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
|
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
|
||||||
-C|-p)
|
-C|-p)
|
||||||
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
|
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
|
||||||
|
--patch-format)
|
||||||
|
shift ; patch_format="$1" ;;
|
||||||
--reject)
|
--reject)
|
||||||
git_apply_opt="$git_apply_opt $1" ;;
|
git_apply_opt="$git_apply_opt $1" ;;
|
||||||
--committer-date-is-author-date)
|
--committer-date-is-author-date)
|
||||||
@ -274,10 +303,10 @@ else
|
|||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
|
|
||||||
rm -fr "$dotest"
|
check_patch_format "$@"
|
||||||
exit 1
|
|
||||||
}
|
split_patches "$@"
|
||||||
|
|
||||||
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
|
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
|
||||||
# for the resuming session after a patch failure.
|
# for the resuming session after a patch failure.
|
||||||
|
Loading…
Reference in New Issue
Block a user