]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-apply.c
pack-objects: Fix segfault when object count is less than thread count
[thirdparty/git.git] / builtin-apply.c
index bd94a4bdb02cae54641cc56582c9b9155cdeb4dd..15432b6782400b556333ee4117c7daaff20412ab 100644 (file)
@@ -1587,8 +1587,7 @@ static int apply_line(char *output, const char *patch, int plen,
                } else if (ch == ' ') {
                        last_space_in_indent = i;
                        if ((ws_rule & WS_INDENT_WITH_NON_TAB) &&
-                           last_tab_in_indent <= 0 &&
-                           8 <= i)
+                           8 <= i - last_tab_in_indent)
                                need_fix_leading_space = 1;
                }
                else
@@ -2908,7 +2907,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
                            whitespace_error,
                            whitespace_error == 1 ? "" : "s",
                            whitespace_error == 1 ? "s" : "");
-               if (applied_after_fixing_ws)
+               if (applied_after_fixing_ws && apply)
                        fprintf(stderr, "warning: %d line%s applied after"
                                " fixing whitespace errors.\n",
                                applied_after_fixing_ws,
@@ -2922,7 +2921,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 
        if (update_index) {
                if (write_cache(newfd, active_cache, active_nr) ||
-                   close(newfd) || commit_locked_index(&lock_file))
+                   commit_locked_index(&lock_file))
                        die("Unable to write new index file");
        }