summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c4730f3)
raw | patch | inline | side by side (parent: c4730f3)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 2 Jul 2008 22:28:22 +0000 (15:28 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 2 Jul 2008 22:28:22 +0000 (15:28 -0700) |
The end of a string is string[length-1], not string[length+1].
I pointed it out during the review, but I forgot about it when applying the
patch. This should fix it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
I pointed it out during the review, but I forgot about it when applying the
patch. This should fix it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | patch | blob | history | |
t/t4128-apply-root.sh | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index bf528966cabd23d844add6dcc6e414a7ca32be7c..6c3db60b659533c612d17852f93fd4ae99519ad6 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
inaccurate_eof = 1;
continue;
}
- if (!strncmp(arg, "--root=", strlen("--root="))) {
+ if (!prefixcmp(arg, "--root=")) {
arg += strlen("--root=");
root_len = strlen(arg);
- if (root_len && arg[root_len + 1] != '/') {
+ if (root_len && arg[root_len - 1] != '/') {
char *new_root;
root = new_root = xmalloc(root_len + 2);
strcpy(new_root, arg);
diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh
index 80b5af2b412d3ecec20bc787261b44af363ea1d1..b6502454556feaf026ad358e18b7c09a62a0c765 100755 (executable)
--- a/t/t4128-apply-root.sh
+++ b/t/t4128-apply-root.sh
mkdir -p some/sub/dir &&
echo Hello > some/sub/dir/file &&
- git add some/sub/dir/file
+ git add some/sub/dir/file &&
+ git commit -m initial &&
+ git tag initial
'
+Bello
EOF
-test_expect_success 'apply --root -p --index' '
+test_expect_success 'apply --root -p (1)' '
git apply --root=some/sub -p3 --index patch &&
test Bello = $(git show :some/sub/dir/file) &&
'
+test_expect_success 'apply --root -p (2) ' '
+
+ git reset --hard initial &&
+ git apply --root=some/sub/ -p3 --index patch &&
+ test Bello = $(git show :some/sub/dir/file) &&
+ test Bello = $(cat some/sub/dir/file)
+
+'
+
test_done