author | Junio C Hamano <gitster@pobox.com> | |
Thu, 21 Jan 2010 04:28:51 +0000 (20:28 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 21 Jan 2010 04:28:51 +0000 (20:28 -0800) |
* ag/patch-header-verify:
builtin-apply.c: fix the --- and +++ header filename consistency check
builtin-apply.c: fix the --- and +++ header filename consistency check
1 | 2 | |||
---|---|---|---|---|
builtin-apply.c | patch | | diff1 | | diff2 | | blob | history |
diff --combined builtin-apply.c
index b99db0b80027685190eb14bf036b8eec8e4f76b2,8ca86f66c8e9bf55f99d5bb7e4d56913e1f74023..2a1004d025fcfdea4d317ef3236ff6bc76e3e65a
--- 1/builtin-apply.c
--- 2/builtin-apply.c
+++ b/builtin-apply.c
{
int i = 0, j = 0;
+ if (!name)
+ return NULL;
+
while (name[i]) {
if ((name[j++] = name[i++]) == '/')
while (name[i] == '/')
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;
if (isnull)
die("git apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
another = find_name(line, NULL, p_value, TERM_TAB);
- if (!another || memcmp(another, name, len))
+ if (!another || memcmp(another, name, len + 1))
die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
free(another);
return orig_name;
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;
return -1;
return 0;
}
- return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID);
+ return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
}
static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)