[PATCH] Fix git-apply with -p greater than 1

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Federico Cuello
Date: Thursday, October 21, 2010 - 3:12 pm

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 <fedux@lugmen.org.ar>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix git-apply with -p greater than 1, Federico Cuello, (Thu Oct 21, 3:12 pm)
Re: [PATCH] Fix git-apply with -p greater than 1, Junio C Hamano, (Thu Oct 21, 10:01 pm)
Re: [PATCH] Fix git-apply with -p greater than 1, Jonathan Nieder, (Thu Oct 21, 10:31 pm)
Re: [PATCH] Fix git-apply with -p greater than 1, Jonathan Nieder, (Fri Oct 22, 8:38 am)
Re: [PATCH] Fix git-apply with -p greater than 1, Junio C Hamano, (Fri Oct 22, 11:40 am)
Re: [PATCH] Fix git-apply with -p greater than 1, Junio C Hamano, (Fri Oct 22, 11:41 am)
Re: [PATCH] Fix git-apply with -p greater than 1, Federico Cuello, (Fri Oct 22, 11:51 am)
[PATCH] Fix git-apply with -p greater than 1, Federico Cuello, (Mon Oct 25, 7:11 am)