tempfile: use list.h for linked list
[gitweb.git] / shallow.c
index c7fd68ace09866ab791b145de6b6317fa909376b..36216febb613969ef5e72b889de65db586ce949d 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -295,10 +295,10 @@ const char *setup_temporary_shallow(const struct oid_array *extra)
        if (write_shallow_commits(&sb, 0, extra)) {
                fd = xmks_tempfile(&temp, git_path("shallow_XXXXXX"));
 
-               if (write_in_full(fd, sb.buf, sb.len) != sb.len)
+               if (write_in_full(fd, sb.buf, sb.len) != sb.len ||
+                   close_tempfile_gently(&temp) < 0)
                        die_errno("failed to write to %s",
                                  get_tempfile_path(&temp));
-               close_tempfile(&temp);
                strbuf_release(&sb);
                return get_tempfile_path(&temp);
        }