git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix git-apply with -p greater than 1
@ 2010-10-21 22:12 Federico Cuello
  2010-10-22  5:01 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Federico Cuello @ 2010-10-21 22:12 UTC (permalink / raw)
  To: git; +Cc: Federico Cuello

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-10-25 14:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-21 22:12 [PATCH] Fix git-apply with -p greater than 1 Federico Cuello
2010-10-22  5:01 ` Junio C Hamano
2010-10-22  5:31   ` Jonathan Nieder
2010-10-22 13:42     ` Fede
2010-10-22 15:38       ` Jonathan Nieder
2010-10-22 18:41       ` Junio C Hamano
2010-10-22 18:51         ` Federico Cuello
2010-10-25 14:11         ` Federico Cuello
2010-10-22 18:40     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).