summaryrefslogtreecommitdiff
path: root/git-am.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-01-21 16:47:14 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-01-21 16:47:14 -0800
commit8318eb795e4bda87d16871ac8ddd5afed033d551 (patch)
tree41c0ac736ec5b313af7c745449b4cada6215ba4b /git-am.sh
parentbash completion: add 'rename' subcommand to git-remote (diff)
parentgit-am: fix shell quoting (diff)
downloadtgif-8318eb795e4bda87d16871ac8ddd5afed033d551.tar.xz
Merge branch 'kb/am-directory'
* kb/am-directory: git-am: fix shell quoting git-am: add --directory=<dir> option
Diffstat (limited to 'git-am.sh')
-rwxr-xr-xgit-am.sh17
1 files changed, 13 insertions, 4 deletions
diff --git a/git-am.sh b/git-am.sh
index 4b157fe5d5..4beb12dcf5 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -16,6 +16,7 @@ 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
whitespace= pass it through git-apply
+directory= pass it through git-apply
C= pass it through git-apply
p= pass it through git-apply
resolvemsg= override error message when patch failure occurs
@@ -33,6 +34,14 @@ cd_to_toplevel
git var GIT_COMMITTER_IDENT >/dev/null ||
die "You need to set your committer info first"
+sq () {
+ for sqarg
+ do
+ printf "%s" "$sqarg" |
+ sed -e 's/'\''/'\''\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
+ done
+}
+
stop_here () {
echo "$1" >"$dotest/next"
exit 1
@@ -155,10 +164,10 @@ do
;;
--resolvemsg)
shift; resolvemsg=$1 ;;
- --whitespace)
- git_apply_opt="$git_apply_opt $1=$2"; shift ;;
+ --whitespace|--directory)
+ git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
-C|-p)
- git_apply_opt="$git_apply_opt $1$2"; shift ;;
+ git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
--)
shift; break ;;
*)
@@ -459,7 +468,7 @@ do
case "$resolved" in
'')
- git apply $git_apply_opt --index "$dotest/patch"
+ eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"'
apply_status=$?
;;
t)