X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=apply.c;h=e87190ea3868f1379d557226e4779c36546ffe3e;hb=89bc8c785e20258efba3b2b5ffc26098fa0b8bc8;hp=81607c0fb6f39a0fb177a16b5f8c7353e97936aa;hpb=e8c80638abc99928dba9ac832589749a531e2e21;p=git.git diff --git a/apply.c b/apply.c index 81607c0f..e87190ea 100644 --- a/apply.c +++ b/apply.c @@ -387,7 +387,7 @@ static char *git_header_name(char *line) default: continue; case '\n': - break; + return NULL; case '\t': case ' ': second = name+len; for (;;) { @@ -1043,8 +1043,12 @@ static int check_patch(struct patch *patch) return error("%s: already exists in working directory", new_name); if (errno != ENOENT) return error("%s: %s", new_name, strerror(errno)); - if (!patch->new_mode) - patch->new_mode = S_IFREG | 0644; + if (!patch->new_mode) { + if (patch->is_new) + patch->new_mode = S_IFREG | 0644; + else + patch->new_mode = patch->old_mode; + } } if (new_name && old_name) { @@ -1373,7 +1377,7 @@ static struct excludes { static int use_patch(struct patch *p) { - const char *pathname = p->new_name ? : p->old_name; + const char *pathname = p->new_name ? p->new_name : p->old_name; struct excludes *x = excludes; while (x) { if (fnmatch(x->path, pathname, 0) == 0)