setup_temporary_shallow: move tempfile struct into function
[gitweb.git] / shallow.c
index f5591e56dab67d6113deb8196c4a68c8af3f2ee0..c7fd68ace09866ab791b145de6b6317fa909376b 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -286,28 +286,27 @@ int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
        return write_shallow_commits_1(out, use_pack_protocol, extra, 0);
 }
 
-static struct tempfile temporary_shallow;
-
 const char *setup_temporary_shallow(const struct oid_array *extra)
 {
+       static struct tempfile temp;
        struct strbuf sb = STRBUF_INIT;
        int fd;
 
        if (write_shallow_commits(&sb, 0, extra)) {
-               fd = xmks_tempfile(&temporary_shallow, git_path("shallow_XXXXXX"));
+               fd = xmks_tempfile(&temp, git_path("shallow_XXXXXX"));
 
                if (write_in_full(fd, sb.buf, sb.len) != sb.len)
                        die_errno("failed to write to %s",
-                                 get_tempfile_path(&temporary_shallow));
-               close_tempfile(&temporary_shallow);
+                                 get_tempfile_path(&temp));
+               close_tempfile(&temp);
                strbuf_release(&sb);
-               return get_tempfile_path(&temporary_shallow);
+               return get_tempfile_path(&temp);
        }
        /*
         * is_repository_shallow() sees empty string as "no shallow
         * file".
         */
-       return get_tempfile_path(&temporary_shallow);
+       return "";
 }
 
 void setup_alternate_shallow(struct lock_file *shallow_lock,