commit_packed_refs(): remove call to `packed_refs_unlock()`
Instead, change the callers of `commit_packed_refs()` to call `packed_refs_unlock()`. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Jun 23, 2017 at 09:01 UTC
42c7f7ff96850a608023c21a5ea05d801e4e5030
2 files changed
+10
-10
refs/files-backend.c
+2
@@ -1131,6 +1131,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
1131
1132
if (commit_packed_refs(refs->packed_ref_store, &err))
1133
die("unable to overwrite old ref-pack file: %s", err.buf);
1134
+ packed_refs_unlock(refs->packed_ref_store);
1135
1136
prune_refs(refs, refs_to_prune);
1137
strbuf_release(&err);
@@ -2699,6 +2700,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
2700
}
2701
2702
cleanup:
2703
+ packed_refs_unlock(refs->packed_ref_store);
2704
transaction->state = REF_TRANSACTION_CLOSED;
2705
string_list_clear(&affected_refnames, 0);
2706
return ret;
refs/packed-backend.c
+8
-10
@@ -606,7 +606,6 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
606
struct packed_ref_cache *packed_ref_cache =
607
get_packed_ref_cache(refs);
608
int ok;
609
- int ret = -1;
609
struct strbuf sb = STRBUF_INIT;
610
FILE *out;
611
struct ref_iterator *iter;
@@ -619,7 +618,7 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
618
strbuf_addf(err, "unable to create file %s: %s",
619
sb.buf, strerror(errno));
620
strbuf_release(&sb);
622
- goto out;
621
+ return -1;
622
}
623
strbuf_release(&sb);
624
@@ -660,18 +659,14 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
659
if (rename_tempfile(&refs->tempfile, refs->path)) {
660
strbuf_addf(err, "error replacing %s: %s",
661
refs->path, strerror(errno));
663
- goto out;
662
+ return -1;
663
}
664
666
- ret = 0;
667
- goto out;
665
+ return 0;
666
667
error:
668
delete_tempfile(&refs->tempfile);
671
-
672
-out:
673
- packed_refs_unlock(ref_store);
674
- return ret;
669
+ return -1;
670
}
671
672
/*
@@ -705,6 +700,7 @@ int repack_without_refs(struct ref_store *ref_store,
700
struct ref_dir *packed;
701
struct string_list_item *refname;
702
int needs_repacking = 0, removed = 0;
703
+ int ret;
704
705
packed_assert_main_repository(refs, "repack_without_refs");
706
assert(err);
@@ -740,7 +736,9 @@ int repack_without_refs(struct ref_store *ref_store,
736
}
737
738
/* Write what remains */
743
- return commit_packed_refs(&refs->base, err);
739
+ ret = commit_packed_refs(&refs->base, err);
740
+ packed_refs_unlock(ref_store);
741
+ return ret;
742
}
743
744
static int packed_init_db(struct ref_store *ref_store, struct strbuf *err)