aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-05-12 14:22:48 -0700
committerJunio C Hamano <gitster@pobox.com>2025-05-12 14:22:49 -0700
commitbd99d6e8db5e2c56dd24395e9711ee7ee564bf4f (patch)
treeb80e6131d230f068d29be426103f2b7fd87150b1 /path.c
parent38758be7fa8269a5223ea6c356939e36492f81b1 (diff)
parent8a9e27be8213ab90ac761d56ac36229ee52c443f (diff)
downloadgit-bd99d6e8db5e2c56dd24395e9711ee7ee564bf4f.tar.xz
Merge branch 'ps/object-store-cleanup'
Further code clean-up in the object-store layer. * ps/object-store-cleanup: object-store: drop `repo_has_object_file()` treewide: convert users of `repo_has_object_file()` to `has_object()` object-store: allow fetching objects via `has_object()` object-store: move function declarations to their respective subsystems object-store: move and rename `odb_pack_keep()` object-store: drop `loose_object_path()` object-store: move `struct packed_git` into "packfile.h"
Diffstat (limited to 'path.c')
-rw-r--r--path.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/path.c b/path.c
index 4505bb78e8..3b598b2847 100644
--- a/path.c
+++ b/path.c
@@ -1011,6 +1011,20 @@ enum scld_error safe_create_leading_directories_const(struct repository *repo,
return result;
}
+int safe_create_file_with_leading_directories(struct repository *repo,
+ const char *path)
+{
+ int fd;
+
+ fd = open(path, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (0 <= fd)
+ return fd;
+
+ /* slow path */
+ safe_create_leading_directories_const(repo, path);
+ return open(path, O_RDWR|O_CREAT|O_EXCL, 0600);
+}
+
static int have_same_root(const char *path1, const char *path2)
{
int is_abs1, is_abs2;