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