]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-apply.c
Merge branch 'jc/maint-1.6.0-blame-s' into maint-1.6.1
[thirdparty/git.git] / builtin-apply.c
index 07244b0736047d6cfe67db7f059f7755906579f0..58d998577e6d4148ddead9e57bdb0999ff026f73 100644 (file)
@@ -630,7 +630,7 @@ static int gitdiff_index(const char *line, struct patch *patch)
        memcpy(patch->new_sha1_prefix, line, len);
        patch->new_sha1_prefix[len] = 0;
        if (*ptr == ' ')
-               patch->new_mode = patch->old_mode = strtoul(ptr+1, NULL, 8);
+               patch->old_mode = strtoul(ptr+1, NULL, 8);
        return 0;
 }
 
@@ -1253,8 +1253,9 @@ static char *inflate_it(const void *data, unsigned long size,
        stream.avail_in = size;
        stream.next_out = out = xmalloc(inflated_size);
        stream.avail_out = inflated_size;
-       inflateInit(&stream);
-       st = inflate(&stream, Z_FINISH);
+       git_inflate_init(&stream);
+       st = git_inflate(&stream, Z_FINISH);
+       git_inflate_end(&stream);
        if ((st != Z_STREAM_END) || stream.total_out != inflated_size) {
                free(out);
                return NULL;
@@ -2435,7 +2436,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
                return error("%s: %s", old_name, strerror(errno));
        }
 
-       if (!cached)
+       if (!cached && !tpatch)
                st_mode = ce_mode_from_stat(*ce, st->st_mode);
 
        if (patch->is_new < 0)
@@ -2447,6 +2448,8 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
        if (st_mode != patch->old_mode)
                fprintf(stderr, "warning: %s has type %o, expected %o\n",
                        old_name, st_mode, patch->old_mode);
+       if (!patch->new_mode && !patch->is_delete)
+               patch->new_mode = st_mode;
        return 0;
 
  is_new: