summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d727f67)
raw | patch | inline | side by side (parent: d727f67)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Jan 2009 06:21:48 +0000 (22:21 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Jan 2009 10:26:01 +0000 (02:26 -0800) |
Thanks to a200337 (git-am: propagate -C<n>, -p<n> options as well,
2008-12-04) and commits around it, "git am" is equipped to correctly
propagate the command line flags such as -C/-p/-whitespace across a patch
failure and restart.
It is trivial to support --directory option now, resurrecting previous
attempts by Kevin and Simon.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-04) and commits around it, "git am" is equipped to correctly
propagate the command line flags such as -C/-p/-whitespace across a patch
failure and restart.
It is trivial to support --directory option now, resurrecting previous
attempts by Kevin and Simon.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-am.txt | patch | blob | history | |
git-am.sh | patch | blob | history | |
t/t4252-am-options.sh | patch | blob | history | |
t/t4252/am-test-5-1 | [new file with mode: 0644] | patch | blob |
t/t4252/am-test-5-2 | [new file with mode: 0644] | patch | blob |
index b9c6fac7483dbefba0afb60a76ac0362aa390a6d..5cbbe7693708bcde50c2fa6717667785579d6722 100644 (file)
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
[verse]
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
[--3way] [--interactive]
- [--whitespace=<option>] [-C<n>] [-p<n>]
+ [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
[<mbox> | <Maildir>...]
'git am' (--skip | --resolved | --abort)
available locally.
--whitespace=<option>::
- This flag is passed to the 'git-apply' (see linkgit:git-apply[1])
- program that applies
- the patch.
-
-C<n>::
-p<n>::
+--directory=<dir>::
These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
diff --git a/git-am.sh b/git-am.sh
index 4b157fe5d536fdbdbf85e0e06c419b5927a90867..7e6329b14c1b7b1b05a76461dc2336ada5df6396 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
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
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
;;
--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 ;;
*)
case "$resolved" in
'')
- git apply $git_apply_opt --index "$dotest/patch"
+ eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"'
apply_status=$?
;;
t)
diff --git a/t/t4252-am-options.sh b/t/t4252-am-options.sh
index 3ab9e8e6e3635ce54b19cec7987ab976fd994309..e91a6da0d50e432ea964b73285923f63f9965f48 100755 (executable)
--- a/t/t4252-am-options.sh
+++ b/t/t4252-am-options.sh
grep "^Three$" file-2
'
+test_expect_success 'interrupted am --directory="frotz nitfol"' '
+ rm -rf .git/rebase-apply &&
+ git reset --hard initial &&
+ test_must_fail git am --directory="frotz nitfol" "$tm"/am-test-5-? &&
+ git am --skip &&
+ grep One "frotz nitfol/file-5"
+'
+
test_done
diff --git a/t/t4252/am-test-5-1 b/t/t4252/am-test-5-1
--- /dev/null
+++ b/t/t4252/am-test-5-1
@@ -0,0 +1,20 @@
+From: A U Thor <au.thor@example.com>
+Date: Thu Dec 4 16:00:00 2008 -0800
+Subject: Six
+
+Applying this patch with --directory='frotz nitfol' should fail
+
+diff --git i/junk/file-2 w/junk/file-2
+index 06e567b..b6f3a16 100644
+--- i/junk/file-2
++++ w/junk/file-2
+@@ -1,7 +1,7 @@
+ One
+ 2
+-3
++Three
+ 4
+ 5
+-6
++Six
+ 7
diff --git a/t/t4252/am-test-5-2 b/t/t4252/am-test-5-2
--- /dev/null
+++ b/t/t4252/am-test-5-2
@@ -0,0 +1,15 @@
+From: A U Thor <au.thor@example.com>
+Date: Thu Dec 4 16:00:00 2008 -0800
+Subject: Six
+
+Applying this patch with --directory='frotz nitfol' should succeed
+
+diff --git i/file-5 w/file-5
+new file mode 100644
+index 000000..1d6ed9f
+--- /dev/null
++++ w/file-5
+@@ -0,0 +1,3 @@
++One
++two
++three