* "packed-refs" file. Note that this (and thus the enclosing
* `packed_ref_store`) must not be freed.
*/
- struct tempfile tempfile;
+ struct tempfile *tempfile;
};
/*
return -1;
}
- if (close_lock_file(&refs->lock)) {
+ if (close_lock_file_gently(&refs->lock)) {
strbuf_addf(err, "unable to close %s: %s", refs->path, strerror(errno));
+ rollback_lock_file(&refs->lock);
return -1;
}
packed_refs_path = get_locked_file_path(&refs->lock);
strbuf_addf(&sb, "%s.new", packed_refs_path);
free(packed_refs_path);
- if (create_tempfile(&refs->tempfile, sb.buf) < 0) {
+ refs->tempfile = create_tempfile(sb.buf);
+ if (!refs->tempfile) {
strbuf_addf(err, "unable to create file %s: %s",
sb.buf, strerror(errno));
strbuf_release(&sb);
}
strbuf_release(&sb);
- out = fdopen_tempfile(&refs->tempfile, "w");
+ out = fdopen_tempfile(refs->tempfile, "w");
if (!out) {
strbuf_addf(err, "unable to fdopen packed-refs tempfile: %s",
strerror(errno));
}
if (ok != ITER_DONE) {
- strbuf_addf(err, "unable to write packed-refs file: "
- "error iterating over old contents");
+ strbuf_addstr(err, "unable to write packed-refs file: "
+ "error iterating over old contents");
goto error;
}
- if (close_tempfile(&refs->tempfile)) {
+ if (close_tempfile_gently(refs->tempfile)) {
strbuf_addf(err, "error closing file %s: %s",
- get_tempfile_path(&refs->tempfile),
+ get_tempfile_path(refs->tempfile),
strerror(errno));
strbuf_release(&sb);
+ delete_tempfile(&refs->tempfile);
return -1;
}
write_error:
strbuf_addf(err, "error writing to %s: %s",
- get_tempfile_path(&refs->tempfile), strerror(errno));
+ get_tempfile_path(refs->tempfile), strerror(errno));
error:
if (iter)
if (data) {
string_list_clear(&data->updates, 0);
- if (is_tempfile_active(&refs->tempfile))
+ if (is_tempfile_active(refs->tempfile))
delete_tempfile(&refs->tempfile);
if (data->own_lock && is_lock_file_locked(&refs->lock)) {
die("BUG: packed reference store does not support renaming references");
}
+static int packed_copy_ref(struct ref_store *ref_store,
+ const char *oldrefname, const char *newrefname,
+ const char *logmsg)
+{
+ die("BUG: packed reference store does not support copying references");
+}
+
static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store)
{
return empty_ref_iterator_begin();
packed_create_symref,
packed_delete_refs,
packed_rename_ref,
+ packed_copy_ref,
packed_ref_iterator_begin,
packed_read_raw_ref,