From: Andreas Gruenbacher <agruen@suse.de>
To: git@vger.kernel.org
Subject: [PATCH] builtin-apply.c: Skip filenames without enough components
Date: Sun, 17 Jan 2010 03:05:10 +0100 [thread overview]
Message-ID: <201001170305.10793.agruen@suse.de> (raw)
find_name() wrongly returned the whole filename for filenames without
enough leading pathname components (e.g., when applying a patch to a
top-level file with -p2).
Include the -p value used in the error message when no filenames can be
found.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
builtin-apply.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 541493e..b99db0b 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -404,6 +404,9 @@ static char *squash_slash(char *name)
{
int i = 0, j = 0;
+ if (!name)
+ return NULL;
+
while (name[i]) {
if ((name[j++] = name[i++]) == '/')
while (name[i] == '/')
@@ -416,7 +419,10 @@ static char *squash_slash(char *name)
static char *find_name(const char *line, char *def, int p_value, int terminate)
{
int len;
- const char *start = line;
+ const char *start = NULL;
+
+ if (p_value == 0)
+ start = line;
if (*line == '"') {
struct strbuf name = STRBUF_INIT;
@@ -1199,7 +1205,8 @@ static int find_header(char *line, unsigned long size, int *hdrsize,
struct patc
continue;
if (!patch->old_name && !patch->new_name) {
if (!patch->def_name)
- die("git diff header lacks filename information (line %d)", linenr);
+ die("git diff header lacks filename information when removing "
+ "%d leading pathname components (line %d)" , p_value, linenr);
patch->old_name = patch->new_name = patch->def_name;
}
patch->is_toplevel_relative = 1;
--
1.6.6.197.g9c4a28
next reply other threads:[~2010-01-17 2:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-17 2:05 Andreas Gruenbacher [this message]
2010-01-17 2:22 ` [PATCH] builtin-apply.c: Skip filenames without enough components Junio C Hamano
2010-01-17 2:44 ` Andreas Gruenbacher
2010-01-18 10:22 ` Nanako Shiraishi
2010-01-18 19:57 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201001170305.10793.agruen@suse.de \
--to=agruen@suse.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).