Sync with 2.5.1
[gitweb.git] / notes-merge.c
index 109ff4ef410b77a814cca282f728f1b88948e4ec..b3d1dab51fb9e7aea4af05211326a1a91b1279d7 100644 (file)
@@ -280,7 +280,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)
                                    "(%s exists).", git_path("NOTES_MERGE_*"));
                }
 
-               if (safe_create_leading_directories(git_path(
+               if (safe_create_leading_directories_const(git_path(
                                NOTES_MERGE_WORKTREE "/.test")))
                        die_errno("unable to create directory %s",
                                  git_path(NOTES_MERGE_WORKTREE));
@@ -295,8 +295,8 @@ static void write_buf_to_worktree(const unsigned char *obj,
                                  const char *buf, unsigned long size)
 {
        int fd;
-       char *path = git_path(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
-       if (safe_create_leading_directories(path))
+       char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
+       if (safe_create_leading_directories_const(path))
                die_errno("unable to create directory for '%s'", path);
        if (file_exists(path))
                die("found existing file at '%s'", path);
@@ -320,6 +320,7 @@ static void write_buf_to_worktree(const unsigned char *obj,
        }
 
        close(fd);
+       free(path);
 }
 
 static void write_note_to_worktree(const unsigned char *obj,