Merge branch 'maint'
* maint: builtin-apply.c: pay attention to -p<n> when determining the name
This commit is contained in:
@ -823,12 +823,13 @@ static int gitdiff_unrecognized(const char *line, struct patch *patch)
|
|||||||
|
|
||||||
static const char *stop_at_slash(const char *line, int llen)
|
static const char *stop_at_slash(const char *line, int llen)
|
||||||
{
|
{
|
||||||
|
int nslash = p_value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < llen; i++) {
|
for (i = 0; i < llen; i++) {
|
||||||
int ch = line[i];
|
int ch = line[i];
|
||||||
if (ch == '/')
|
if (ch == '/' && --nslash <= 0)
|
||||||
return line + i;
|
return &line[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,23 @@ test_expect_success 'apply --directory (new file)' '
|
|||||||
test content = $(cat some/sub/dir/newfile)
|
test content = $(cat some/sub/dir/newfile)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat > patch << EOF
|
||||||
|
diff --git a/c/newfile2 b/c/newfile2
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..d95f3ad
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/c/newfile2
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+content
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'apply --directory -p (new file)' '
|
||||||
|
git reset --hard initial &&
|
||||||
|
git apply -p2 --directory=some/sub/dir/ --index patch &&
|
||||||
|
test content = $(git show :some/sub/dir/newfile2) &&
|
||||||
|
test content = $(cat some/sub/dir/newfile2)
|
||||||
|
'
|
||||||
|
|
||||||
cat > patch << EOF
|
cat > patch << EOF
|
||||||
diff --git a/delfile b/delfile
|
diff --git a/delfile b/delfile
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
|
Reference in New Issue
Block a user