@matheusbsbs / matheus-bagliano / commits / 64224caf88
Fork 0

refs.c: make sure leading directories exist before writing a ref.

Otherwise cloning a repository with hierarchical branch/tag over http would fail. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 7, 2005 at 17:48 UTC 64224caf888253601b7285ab242f4a12779894b9
1 file changed +4
refs.c
+4
@@ -292,6 +292,8 @@ int write_ref_sha1(const char *ref, int fd, const unsigned char *sha1)
292 return -1;
293 filename = ref_file_name(ref);
294 lock_filename = ref_lock_file_name(ref);
295 + if (safe_create_leading_directories(filename))
296 + die("unable to create leading directory for %s", filename);
297 retval = write_ref_file(filename, lock_filename, fd, sha1);
298 free(filename);
299 free(lock_filename);
@@ -358,6 +360,8 @@ int write_ref_sha1_unlocked(const char *ref, const unsigned char *sha1)
360 return -1;
361 filename = ref_file_name(ref);
362 lock_filename = ref_lock_file_name(ref);
363 + if (safe_create_leading_directories(filename))
364 + die("unable to create leading directory for %s", filename);
365 fd = open(lock_filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
366 if (fd < 0) {
367 error("Writing %s", lock_filename);