git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git apply: binary files differ can be applied with -pN (N>1).
@ 2010-11-24  5:20 Jiang Xin
  2010-11-24  6:53 ` Jiang Xin
  2010-11-24 17:20 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Jiang Xin @ 2010-11-24  5:20 UTC (permalink / raw)
  To: git, gitster

When patch file generated against two non-git directories using
'git diff --binary --no-index' without '--no-prefix', the patch
file has patch level greater then 1, and should be applied with
'-p2' option. But it does not work if there are binary differ
in the patch file, it is because in one case the patch level is
not properly handled.

Signed-off-by: Jiang Xin <jiangxin@ossxp.com>
---
 builtin/apply.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 23c18c5..d603e37 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1126,6 +1126,7 @@ static char *git_header_name(char *line, int llen)
 	 * form.
 	 */
 	for (len = 0 ; ; len++) {
+		int nslash = p_value;
 		switch (name[len]) {
 		default:
 			continue;
@@ -1137,7 +1138,7 @@ static char *git_header_name(char *line, int llen)
 				char c = *second++;
 				if (c == '\n')
 					return NULL;
-				if (c == '/')
+				if (c == '/' && --nslash <= 0)
 					break;
 			}
 			if (second[len] == '\n' && !memcmp(name, second, len)) {
-- 
1.7.3.2.245.g03276.dirty

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

end of thread, other threads:[~2010-11-25  2:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-24  5:20 [PATCH] git apply: binary files differ can be applied with -pN (N>1) Jiang Xin
2010-11-24  6:53 ` Jiang Xin
2010-11-24 17:20 ` Junio C Hamano
2010-11-25  1:46   ` Jiang Xin
2010-11-25  2:52     ` Jiang Xin

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