Skip to content

Commit

Permalink
create_tempfile: make sure that leading directories can be accessible…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Junio C Hamano committed Jun 17, 2008
1 parent 1421c5f commit 3bfaf01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 3bfaf01

Please sign in to comment.