[PATCH] clone-pack.c:write_one_ref() - Create leading directories.

The function write_one_ref() is passed the list of refs received
from the other end, which was obtained by directory traversal
under $GIT_DIR/refs; this can contain paths other than what
git-init-db prepares and would fail to clone when there is
such.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Junio C Hamano
2005-07-06 01:11:52 -07:00
committed by Linus Torvalds
parent ff9206e72c
commit b2cb94254b
3 changed files with 25 additions and 1 deletions

View File

@ -68,9 +68,12 @@ static int is_master(struct ref *ref)
static void write_one_ref(struct ref *ref)
{
char *path = git_path(ref->name);
int fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
int fd;
char *hex;
if (safe_create_leading_directories(path))
die("unable to create leading directory for %s", ref->name);
fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd < 0)
die("unable to create ref %s", ref->name);
hex = sha1_to_hex(ref->sha1);