summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-21 22:53:36 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-21 22:53:36 -0700
commit2990034f1ed2c3d85d23d5611a1f04d317f785ac (patch)
treeb279df7a87a679a74c942f1c32d42681f9317f4b /wrapper.c
parentbf0fe35c938ac9f03d1369600b0c76e428a57507 (diff)
parent2c626e5fa8a46f647b88fb32d7b28d573e8631bf (diff)
downloadgit-2990034f1ed2c3d85d23d5611a1f04d317f785ac.tar.gz
Merge branch 'jc/maint-1.6.0-pack-directory' into maint-1.6.1
* jc/maint-1.6.0-pack-directory: Fix odb_mkstemp() on AIX Make sure objects/pack exists before creating a new pack Conflicts: wrapper.c
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index c85ca52ec6..d8efb1365a 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -256,3 +256,36 @@ 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 */
+ /* some mkstemp implementations erase template on failure */
+ snprintf(template, limit, "%s/%s",
+ get_object_directory(), pattern);
+ safe_create_leading_directories(template);
+ 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);
+}