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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Andreas Schwab <hidden>
Date: 2016-06-15 22:48:48

Jonathan Nieder [off-list ref] writes:
In your case, all 16384 trials yielded the same result: file already
existed.
IMHO it is much more likely that a race happened between two git
processes each wanting to create the .git/objects/e6 directory.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:48:48

Andreas Schwab wrote:
Jonathan Nieder [off-list ref] writes:
quoted
In your case, all 16384 trials yielded the same result: file already
existed.
IMHO it is much more likely that a race happened between two git
processes each wanting to create the .git/objects/e6 directory.
Good catch.  But wasn’t the problem reproducible?

In any event, that such a race is possible is not so nice.  Here’s
a naïve fix; it does not address other races, such as hash-object
versus prune.  Maybe git ought to acquire some sort of lock before
writing to the object dir in a shared clone.
diff --git a/sha1_file.c b/sha1_file.c
index bbb819f..d305e53 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2244,6 +2244,13 @@ static inline int directory_size(const char *filename)
 	return s - filename + 1;
 }
 
+static int ensure_directory_exists(const char *dir)
+{
+	if (mkdir(dir, 0777) && errno != EEXIST)
+		return -1;
+	return adjust_shared_perm(dir);
+}
+
 /*
  * This creates a temporary file in the same directory as the final
  * 'filename'
@@ -2266,7 +2273,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
 		/* Make sure the directory exists */
 		memcpy(buffer, filename, dirlen);
 		buffer[dirlen-1] = 0;
-		if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
+		if (ensure_directory_exists(buffer))
 			return -1;
 
 		/* Try again */
-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help