From: Federico Cuello Date: Thu, 21 Oct 2010 22:12:02 GMT Subject: [PATCH] Fix git-apply with -p greater than 1 Message-ID: <1287699122-26702-1-git-send-email-fedux@lugmen.org.ar> Fix the case when the patch is a rename or mode-change only and -p is used with a value greater than one. The git_header_name function did not remove more than one path component. Signed-off-by: Federico Cuello --- builtin/apply.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index 23c18c5..14996f8 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -1132,15 +1132,11 @@ static char *git_header_name(char *line, int llen) case '\n': return NULL; case '\t': case ' ': - second = name+len; - for (;;) { - char c = *second++; - if (c == '\n') - return NULL; - if (c == '/') - break; - } - if (second[len] == '\n' && !memcmp(name, second, len)) { + second = stop_at_slash(name + len, (name - line) + len); + if (!second) + return NULL; + second++; + if (second[len] == '\n' && !strncmp(name, second, len)) { return xmemdupz(name, len); } } -- 1.7.3.1