summaryrefslogtreecommitdiff
path: root/index-pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'index-pack.c')
-rw-r--r--index-pack.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/index-pack.c b/index-pack.c
index f7a3807..7fee872 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -172,9 +172,8 @@ static char *open_pack_file(char *pack_name)
input_fd = 0;
if (!pack_name) {
static char tmpfile[PATH_MAX];
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/pack/tmp_pack_XXXXXX", get_object_directory());
- output_fd = xmkstemp(tmpfile);
+ output_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
+ "pack/tmp_pack_XXXXXX");
pack_name = xstrdup(tmpfile);
} else
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
@@ -794,22 +793,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
if (keep_msg) {
int keep_fd, keep_msg_len = strlen(keep_msg);
- if (!keep_name) {
- snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
- get_object_directory(), sha1_to_hex(sha1));
- keep_name = name;
- }
- keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
+
+ if (!keep_name)
+ keep_fd = odb_pack_keep(name, sizeof(name), sha1);
+ else
+ keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
+
if (keep_fd < 0) {
if (errno != EEXIST)
- die("cannot write keep file");
+ die("cannot write keep file '%s' (%s)",
+ keep_name, strerror(errno));
} else {
if (keep_msg_len > 0) {
write_or_die(keep_fd, keep_msg, keep_msg_len);
write_or_die(keep_fd, "\n", 1);
}
if (close(keep_fd) != 0)
- die("cannot write keep file");
+ die("cannot close written keep file '%s' (%s)",
+ keep_name, strerror(errno));
report = "keep";
}
}