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
This commit is contained in:
23
index-pack.c
23
index-pack.c
@ -171,9 +171,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);
|
||||
@ -793,22 +792,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";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user