git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Empty temp files in the .git/objects subdirectories

From
NHNick Hengeveld <nickh@reactrix.com>
Date
Nov 4, 2005, 01:54 UTC
Message-ID
<20051104015452.GB3001@reactrix.com>
In-Reply-To
<dkebkq$ova$1@sea.gmane.org>
On Thu, Nov 03, 2005 at 04:56:58PM -0800, walt wrote:
> I've noticed (sometimes) after using cg-update to
> pull from Linus's kernel tree, that I have multiple
> empty files named *.temp in the various subdirectories
> of .git/objects/.

These are created by git-http-fetch to hold data as it's being fetch from the remote repository. They are left behind after a transfer error so that the next time git-http-fetch runs it can pick up where it left off. If they're empty though, it would make more sense to delete them rather than leaving them behind for the next attempt.

This should fix it:
[PATCH] Remove the temp file if it is empty after the request has failed
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
---
 http-fetch.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

applies-to: 55caf3fd962e3b5a25ee12e09c781e6f5a240672 28738a32636e9f0a326f5d9e662df1e6c594851f

diff --git a/http-fetch.c b/http-fetch.c
index a1b03cd..b12779d 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -520,12 +520,17 @@ static void start_request(struct transfe
 
 static void finish_request(struct transfer_request *request)
 {
+	struct stat st;
+
 	fchmod(request->local, 0444);
 	close(request->local);
 
 	if (request->http_code == 416) {
 		fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
 	} else if (request->curl_result != CURLE_OK) {
+		if (stat(request->tmpfile, &st) == 0)
+			if (st.st_size == 0)
+				unlink(request->tmpfile);
 		return;
 	}
 
---
0.99.9.GIT
Previous: waltNext: Junio C Hamano
Message 2 of 3 in “Empty temp files in the .git/objects subdirectories”
  1. waltNov 4, 2005
  2. Nick HengeveldNov 4, 2005
  3. Junio C HamanoNov 4, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.