X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-apply.c;h=3af4ae0c269bc8a2cb1bb4240af1f191d2ba0442;hb=7c0be4da5cab4efd89ee6583f7009d648a75a725;hp=8ca86f66c8e9bf55f99d5bb7e4d56913e1f74023;hpb=da915939fd7523cd145ba280cc974d46aa792331;p=git.git diff --git a/builtin-apply.c b/builtin-apply.c index 8ca86f66c..3af4ae0c2 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; @@ -1999,7 +2006,7 @@ static int find_pos(struct image *img, return -1; /* - * If match_begining or match_end is specified, there is no + * If match_beginning or match_end is specified, there is no * point starting from a wrong line that will never match and * wander around and wait for a match at the specified end. */ @@ -2666,7 +2673,7 @@ static int verify_index_match(struct cache_entry *ce, struct stat *st) 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)