Code

fsck.c: fix bogus "empty tree" check
[git.git] / builtin-checkout-index.c
index e6264c4bf0ef537ea7ea2127133d1fad5a33b7d6..7e42024c67a2c0fda72f94935b7d5a723c73d131 100644 (file)
@@ -66,9 +66,7 @@ static void write_tempfile_record(const char *name, int prefix_length)
                fputs(topath[checkout_stage], stdout);
 
        putchar('\t');
-       write_name_quoted("", 0, name + prefix_length,
-               line_termination, stdout);
-       putchar(line_termination);
+       write_name_quoted(name + prefix_length, stdout, line_termination);
 
        for (i = 0; i < 4; i++) {
                topath[i][0] = 0;
@@ -248,8 +246,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                 * want to update cache.
                 */
                if (state.refresh_cache) {
-                       close(newfd); newfd = -1;
                        rollback_lock_file(&lock_file);
+                       newfd = -1;
                }
                state.refresh_cache = 0;
        }
@@ -299,7 +297,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
 
        if (0 <= newfd &&
            (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");
        return 0;
 }