Git development
 help / color / mirror / Atom feed
* [PATCH] sha1_file: make sure correct error is propagated
@ 2008-11-14  7:19 Sam Vilain
  2008-11-14  7:44 ` Francis Galiegue
  0 siblings, 1 reply; 9+ messages in thread
From: Sam Vilain @ 2008-11-14  7:19 UTC (permalink / raw)
  To: git; +Cc: Sam Vilain, Sam Vilain

From: Sam Vilain <samv@maia.lan>

In the case that a object directory exists, but is not writable, the
code path that tries to create it is followed and the returned errno
and path that of the directory tried to be created.  The resultant
error message is confusing.

So, if the mkstemp() fails with EPERM, don't try to create the
directory - return straight away.

Signed-off-by: Sam Vilain <sam@vilain.net>
---
 sha1_file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index ab2b520..7662330 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2231,7 +2231,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
 	memcpy(buffer, filename, dirlen);
 	strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
 	fd = mkstemp(buffer);
-	if (fd < 0 && dirlen) {
+	if (fd < 0 && dirlen && (errno != EPERM)) {
 		/* Make sure the directory exists */
 		memcpy(buffer, filename, dirlen);
 		buffer[dirlen-1] = 0;
-- 
debian.1.5.6.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-11-15  6:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-14  7:19 [PATCH] sha1_file: make sure correct error is propagated Sam Vilain
2008-11-14  7:44 ` Francis Galiegue
2008-11-14  9:41   ` Sam Vilain
2008-11-14 19:05     ` Junio C Hamano
2008-11-14 19:09       ` Francis Galiegue
2008-11-14 19:50         ` Andreas Ericsson
2008-11-14 20:08           ` Francis Galiegue
2008-11-15  5:44         ` Junio C Hamano
2008-11-15  6:30           ` Sam Vilain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox