X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=apply.c;h=8a3ead6c949ecc0a493f9525580fd90d6bc6ebcd;hb=ef0bfa25e99627b809c0902d21072821955db3fe;hp=cf40e5d4b668d59a96adb1e1a14c42fa6cce6370;hpb=84fb9a4dca7efe1427c917e2f46a045e48180826;p=git.git diff --git a/apply.c b/apply.c index cf40e5d4b..8a3ead6c9 100644 --- a/apply.c +++ b/apply.c @@ -570,8 +570,11 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc int git_hdr_len = parse_git_header(line, len, size, patch); if (git_hdr_len <= len) continue; - if (!patch->old_name && !patch->new_name) - die("git diff header lacks filename information (line %d)", linenr); + if (!patch->old_name && !patch->new_name) { + if (!patch->def_name) + die("git diff header lacks filename information (line %d)", linenr); + patch->old_name = patch->new_name = patch->def_name; + } *hdrsize = git_hdr_len; return offset; } @@ -748,9 +751,11 @@ static void show_stats(struct patch *patch) del = patch->lines_deleted; total = add + del; - total = (total * max + max_change / 2) / max_change; - add = (add * max + max_change / 2) / max_change; - del = total - add; + if (max_change > 0) { + total = (total * max + max_change / 2) / max_change; + add = (add * max + max_change / 2) / max_change; + del = total - add; + } printf(" %-*s |%5d %.*s%.*s\n", len, name, patch->lines_added + patch->lines_deleted, add, pluses, del, minuses); @@ -1000,6 +1005,7 @@ static int check_patch(struct patch *patch) } if (patch->is_new < 0) patch->is_new = 0; + st.st_mode = ntohl(create_ce_mode(st.st_mode)); if (!patch->old_mode) patch->old_mode = st.st_mode; if ((st.st_mode ^ patch->old_mode) & S_IFMT)