git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Pitre <nico@cam.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] make it more obvious that temporary files are temporary files
Date: Sat, 24 Mar 2007 11:58:22 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.0.83.0703241151010.18328@xanadu.home> (raw)

When some operations are interrupted (or "die()'d" or crashed) then the 
partial object/pack/index file may remain around.  Make it more obvious 
in their name that those files are temporary stuff and can be cleaned up 
if no operation is in progress.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---

diff --git a/fast-import.c b/fast-import.c
index 55ffae4..bea1215 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -630,7 +630,7 @@ static void start_packfile(void)
 	int pack_fd;
 
 	snprintf(tmpfile, sizeof(tmpfile),
-		"%s/pack_XXXXXX", get_object_directory());
+		"%s/tmp_pack_XXXXXX", get_object_directory());
 	pack_fd = mkstemp(tmpfile);
 	if (pack_fd < 0)
 		die("Can't create %s: %s", tmpfile, strerror(errno));
@@ -730,7 +730,7 @@ static char *create_index(void)
 	}
 
 	snprintf(tmpfile, sizeof(tmpfile),
-		"%s/index_XXXXXX", get_object_directory());
+		"%s/tmp_idx_XXXXXX", get_object_directory());
 	idx_fd = mkstemp(tmpfile);
 	if (idx_fd < 0)
 		die("Can't create %s: %s", tmpfile, strerror(errno));
diff --git a/index-pack.c b/index-pack.c
index 61eb20e..6284fe3 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -139,7 +139,7 @@ static const char *open_pack_file(const char *pack_name)
 		if (!pack_name) {
 			static char tmpfile[PATH_MAX];
 			snprintf(tmpfile, sizeof(tmpfile),
-				 "%s/pack_XXXXXX", get_object_directory());
+				 "%s/tmp_pack_XXXXXX", get_object_directory());
 			output_fd = mkstemp(tmpfile);
 			pack_name = xstrdup(tmpfile);
 		} else
@@ -690,7 +690,7 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
 	if (!index_name) {
 		static char tmpfile[PATH_MAX];
 		snprintf(tmpfile, sizeof(tmpfile),
-			 "%s/index_XXXXXX", get_object_directory());
+			 "%s/tmp_idx_XXXXXX", get_object_directory());
 		fd = mkstemp(tmpfile);
 		index_name = xstrdup(tmpfile);
 	} else {
diff --git a/sha1_file.c b/sha1_file.c
index 940bab5..0897b94 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1979,7 +1979,7 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
 		return error("sha1 file %s: %s\n", filename, strerror(errno));
 	}
 
-	snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
+	snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
 
 	fd = mkstemp(tmpfile);
 	if (fd < 0) {
@@ -2105,7 +2105,7 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
 	int ret;
 	SHA_CTX c;
 
-	snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
+	snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
 
 	local = mkstemp(tmpfile);
 	if (local < 0) {

                 reply	other threads:[~2007-03-24 15:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.0.83.0703241151010.18328@xanadu.home \
    --to=nico@cam.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).