Skip to contentSkip to conversation

Empty temp files in the .git/objects subdirectories

DISCUSSION walt 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore

walt

author
#0 lore raw

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 *.temp files don't exist in Linus's repository on kernel.org, so I am assuming they must be created locally at my end by either cogito or git (dunno which).

They cause no problems except for annoying warning messages, for example, while doing a git-fsck-*.

I'm using git and cogito(HEAD), both updated by using cg-update from their git repositories on kernel.org, so I'm current up to the very last minute :o)

Any suggestions how I can discover who is leaving behind all these spurious empty *.temp files?

#1 lore raw
Quoted 4 lines · walt

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

---

 http-fetch.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

applies-to: 55caf3fd962e3b5a25ee12e09c781e6f5a240672 28738a32636e9f0a326f5d9e662df1e6c594851f

http-fetch.c +5 -0
index a1b03cd..b12779d 100644
@@ -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

#2 lore raw
Quoted 5 lines · Nick Hengeveld

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.

That makes sense. Thanks.