Thread (5 messages) flat view 5 messages, 4 authors, 2016-06-15

Re: [remote rejected] master -> master (n/a (unpacker error))

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:48:47
Subsystem: the rest · Maintainer: Linus Torvalds

Hi Robert,

Robert Buck wrote:
error: unable to create temporary sha1 filename ./objects/e6: File exists
Yeah, this error message is not so great.

The relevant code is in sha1_file.c.

	fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
	while (fd < 0 && errno == EMFILE && unuse_one_window(packed_git, -1))
		fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
	if (fd < 0) {
		if (errno == EACCES)
			return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
		else
			return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
	}

create_tmpfile() creates a filename of the form
./objects/e6/tmp_obj_<random letters> and tries to open that file.
The random value is based on the current time and the process ID of
the current process.  If the file exists, it tries again with another
collection of random letters, up to 16384 times.

In your case, all 16384 trials yielded the same result: file already
existed.  As a workaround, I’d suggest

 rm -f .git/objects/??/tmp_obj_*

but it might be nice to get a listing with "ls -lR .git/objects" first
for post-mortem analysis.

And presumably the directory filled with temporary files that could
not be renamed to a proper name for some reason.  Probably a permissions
problem, as Chris suggested.

-- 8< --
Subject: write_loose_object(): improve error message for some mkstemp failures

If the .git/objects/ab/ directory fills up with tmp_obj_ files, the
result is a cryptic error:

  error: unable to create temporary sha1 filename ./objects/e6: File exists

Replace it with the slightly less cryptic

  error: cannot write temporary file under ./objects/e6: all the good filenames are taken

Reported-by: Robert Buck <redacted>
Signed-off-by: Jonathan Nieder <redacted>
---
As an aside, where the heck is the git bug tracker?
Here is an answer from the last time it came up[1]:

 See http://thread.gmane.org/gmane.comp.version-control.git/136500

 Short answer: the usual method is to report bugs to the list,
 preferably with a patch for t/ or even better, a fix. 
I've searched, and
searched, and ... All I found is a Debian tracking system, which
appears to have no full text search capabilities.
http://merkel.debian.org/~don/cgi/search.cgi
http://www.google.com/search?q=site:bugs.debian.org+"Package:+git"+"file+exists"

Thoughts?  Improvements?
Jonathan

[1] http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/680778/focus=141598

 sha1_file.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 28c056e..a2aa301 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2288,6 +2288,10 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 	if (fd < 0) {
 		if (errno == EACCES)
 			return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
+		else if (errno == EEXIST)
+			return error("cannot write temporary file under %s: "
+			             "all the good filenames are taken\n",
+			             tmpfile);
 		else
 			return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
 	}
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help