aboutsummaryrefslogtreecommitdiff
path: root/t/t4119-apply-config.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-19 17:57:29 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-19 18:44:59 -0800
commit56185f49d03cae28048146e902089ea366c6cd6c (patch)
tree93fccbc9ac5e8c80f731d2303c2522ea2fe6dd1a /t/t4119-apply-config.sh
parentaea1945744214bf84908586af8be1c098a6f346d (diff)
downloadgit-56185f49d03cae28048146e902089ea366c6cd6c.tar.gz
git-56185f49d03cae28048146e902089ea366c6cd6c.tar.xz
git-apply: require -p<n> when working in a subdirectory.
git-apply running inside a subdirectory, with or without --index, used to always assume that the patch is formatted in such a way to apply with -p1 from the toplevel, but it is more useful and consistent with the use of "GNU patch -p1" if it defaulted to assume that its input is meant to apply at the level it is invoked in. This changes the behaviour. It used to be that the patch generated this way would apply without any trick: edit Documentation/Makefile git diff >patch.file cd Documentation git apply ../patch.file You need to give an explicit -p2 to git-apply now. On the other hand, if you got a patch from somebody else who did not follow "patch is to apply from the top with -p1" convention, the input patch would start with: diff -u Makefile.old Makefile --- Makefile.old +++ Makefile and in such a case, you can apply it with: git apply -p0 patch.file Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 't/t4119-apply-config.sh')
-rwxr-xr-xt/t4119-apply-config.sh32
1 files changed, 18 insertions, 14 deletions
diff --git a/t/t4119-apply-config.sh b/t/t4119-apply-config.sh
index 0e8ea7e2b..816b5b8fb 100755
--- a/t/t4119-apply-config.sh
+++ b/t/t4119-apply-config.sh
@@ -10,20 +10,22 @@ test_description='git-apply --whitespace=strip and configuration file.
. ./test-lib.sh
test_expect_success setup '
- echo A >file1 &&
- cp file1 saved &&
- git add file1 &&
- echo "B " >file1 &&
+ mkdir sub &&
+ echo A >sub/file1 &&
+ cp sub/file1 saved &&
+ git add sub/file1 &&
+ echo "B " >sub/file1 &&
git diff >patch.file
'
test_expect_success 'apply --whitespace=strip' '
- cp saved file1 &&
+ rm -f sub/file1 &&
+ cp saved sub/file1 &&
git update-index --refresh &&
git apply --whitespace=strip patch.file &&
- if grep " " file1
+ if grep " " sub/file1
then
echo "Eh?"
false
@@ -34,12 +36,13 @@ test_expect_success 'apply --whitespace=strip' '
test_expect_success 'apply --whitespace=strip from config' '
- cp saved file1 &&
+ rm -f sub/file1 &&
+ cp saved sub/file1 &&
git update-index --refresh &&
git config apply.whitespace strip &&
git apply patch.file &&
- if grep " " file1
+ if grep " " sub/file1
then
echo "Eh?"
false
@@ -48,19 +51,19 @@ test_expect_success 'apply --whitespace=strip from config' '
fi
'
-mkdir sub
D=`pwd`
test_expect_success 'apply --whitespace=strip in subdir' '
cd "$D" &&
git config --unset-all apply.whitespace
- cp saved file1 &&
+ rm -f sub/file1 &&
+ cp saved sub/file1 &&
git update-index --refresh &&
cd sub &&
- git apply --whitespace=strip ../patch.file &&
- if grep " " ../file1
+ git apply --whitespace=strip -p2 ../patch.file &&
+ if grep " " file1
then
echo "Eh?"
false
@@ -73,11 +76,12 @@ test_expect_success 'apply --whitespace=strip from config in subdir' '
cd "$D" &&
git config apply.whitespace strip &&
- cp saved file1 &&
+ rm -f sub/file1 &&
+ cp saved sub/file1 &&
git update-index --refresh &&
cd sub &&
- git apply ../patch.file &&
+ git apply -p2 ../patch.file &&
if grep " " file1
then
echo "Eh?"