summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-25 22:48:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-02-25 22:50:05 (GMT)
commitbb0cebd7d0ac9bf2ddf94fe5579603819c4a1fc7 (patch)
tree1fdfa7e92aa0290bacfb64d77aad894d9915785a /wrapper.c
parent69707d616fd3acda6ecc47198edeaaa87f2cfcea (diff)
parent6e180cdcecbb3e828aa892925d7ef67abf81ad80 (diff)
downloadgit-bb0cebd7d0ac9bf2ddf94fe5579603819c4a1fc7.zip
git-bb0cebd7d0ac9bf2ddf94fe5579603819c4a1fc7.tar.gz
git-bb0cebd7d0ac9bf2ddf94fe5579603819c4a1fc7.tar.bz2
Merge branch 'jc/maint-1.6.0-pack-directory'
* jc/maint-1.6.0-pack-directory: Make sure objects/pack exists before creating a new pack
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index c85ca52..b07cdf2 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -256,3 +256,35 @@ int git_inflate(z_streamp strm, int flush)
error("inflate: %s (%s)", err, strm->msg ? strm->msg : "no message");
return ret;
}
+
+int odb_mkstemp(char *template, size_t limit, const char *pattern)
+{
+ int fd;
+
+ snprintf(template, limit, "%s/%s",
+ get_object_directory(), pattern);
+ fd = mkstemp(template);
+ if (0 <= fd)
+ return fd;
+
+ /* slow path */
+ safe_create_leading_directories(template);
+ snprintf(template, limit, "%s/%s",
+ get_object_directory(), pattern);
+ return xmkstemp(template);
+}
+
+int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
+{
+ int fd;
+
+ snprintf(name, namesz, "%s/pack/pack-%s.keep",
+ get_object_directory(), sha1_to_hex(sha1));
+ fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (0 <= fd)
+ return fd;
+
+ /* slow path */
+ safe_create_leading_directories(name);
+ return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+}