summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-06-16 22:02:12 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-16 22:02:12 -0700
commit3bfaf01857ebcefbd38529a73b059dc984ecb5a4 (patch)
tree091e2c0bd44983126a75707c43ae1bec053e6b87
parent1421c5f274a10f93ce5e8b51c0e1351905f84f4e (diff)
downloadgit-3bfaf01857ebcefbd38529a73b059dc984ecb5a4.tar.gz
create_tempfile: make sure that leading directories can be accessible by peers
In a shared repository, we should make sure adjust_shared_perm() is called after creating the initial fan-out directories under objects/ directory. Earlier an logico called the function only when mkdir() failed; we should do so when mkdir() succeeded. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sha1_file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 500584b643..e300562c15 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -116,7 +116,7 @@ int safe_create_leading_directories(char *path)
return 0;
}
-char * sha1_to_hex(const unsigned char *sha1)
+char *sha1_to_hex(const unsigned char *sha1)
{
static int bufno;
static char hexbuffer[4][50];
@@ -2125,7 +2125,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
if (fd < 0 && dirlen) {
/* Make sure the directory exists */
buffer[dirlen-1] = 0;
- if (mkdir(buffer, 0777) && adjust_shared_perm(buffer))
+ if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
return -1;
/* Try again */