Merge branch 'kb/am-directory'

* kb/am-directory:
  git-am: fix shell quoting
  git-am: add --directory=<dir> option
This commit is contained in:
Junio C Hamano 2009-01-21 16:47:14 -08:00
Родитель f135e72d61 17f26a9ee3
Коммит 8318eb795e
5 изменённых файлов: 66 добавлений и 9 удалений

Просмотреть файл

@ -11,7 +11,7 @@ SYNOPSIS
[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)
@ -60,12 +60,9 @@ default. You could use `--no-utf8` to override this.
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.

Просмотреть файл

@ -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)

Просмотреть файл

@ -50,4 +50,20 @@ test_expect_success 'interrupted am -C1 -p2' '
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_expect_success 'apply to a funny path' '
with_sq="with'\''sq"
rm -fr .git/rebase-apply &&
git reset --hard initial &&
git am --directory="$with_sq" "$tm"/am-test-5-2 &&
test -f "$with_sq/file-5"
'
test_done

20
t/t4252/am-test-5-1 Normal file
Просмотреть файл

@ -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

15
t/t4252/am-test-5-2 Normal file
Просмотреть файл

@ -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