X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=apply.c;h=e87190ea3868f1379d557226e4779c36546ffe3e;hb=cf6de18aabf774dfce7efd9c59babfe9d909d433;hp=81607c0fb6f39a0fb177a16b5f8c7353e97936aa;hpb=2b64f88f09ae2169ec85652b46897574e352936d;p=git.git diff --git a/apply.c b/apply.c index 81607c0fb..e87190ea3 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)