Skip to content

Commit 42c7f7f

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 9051198 commit 42c7f7f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

refs/files-backend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
11311131

11321132
if (commit_packed_refs(refs->packed_ref_store, &err))
11331133
die("unable to overwrite old ref-pack file: %s", err.buf);
1134+
packed_refs_unlock(refs->packed_ref_store);
11341135

11351136
prune_refs(refs, refs_to_prune);
11361137
strbuf_release(&err);
@@ -2699,6 +2700,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
26992700
}
27002701

27012702
cleanup:
2703+
packed_refs_unlock(refs->packed_ref_store);
27022704
transaction->state = REF_TRANSACTION_CLOSED;
27032705
string_list_clear(&affected_refnames, 0);
27042706
return ret;

refs/packed-backend.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
606606
struct packed_ref_cache *packed_ref_cache =
607607
get_packed_ref_cache(refs);
608608
int ok;
609-
int ret = -1;
610609
struct strbuf sb = STRBUF_INIT;
611610
FILE *out;
612611
struct ref_iterator *iter;
@@ -619,7 +618,7 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
619618
strbuf_addf(err, "unable to create file %s: %s",
620619
sb.buf, strerror(errno));
621620
strbuf_release(&sb);
622-
goto out;
621+
return -1;
623622
}
624623
strbuf_release(&sb);
625624

@@ -660,18 +659,14 @@ int commit_packed_refs(struct ref_store *ref_store, struct strbuf *err)
660659
if (rename_tempfile(&refs->tempfile, refs->path)) {
661660
strbuf_addf(err, "error replacing %s: %s",
662661
refs->path, strerror(errno));
663-
goto out;
662+
return -1;
664663
}
665664

666-
ret = 0;
667-
goto out;
665+
return 0;
668666

669667
error:
670668
delete_tempfile(&refs->tempfile);
671-
672-
out:
673-
packed_refs_unlock(ref_store);
674-
return ret;
669+
return -1;
675670
}
676671

677672
/*
@@ -705,6 +700,7 @@ int repack_without_refs(struct ref_store *ref_store,
705700
struct ref_dir *packed;
706701
struct string_list_item *refname;
707702
int needs_repacking = 0, removed = 0;
703+
int ret;
708704

709705
packed_assert_main_repository(refs, "repack_without_refs");
710706
assert(err);
@@ -740,7 +736,9 @@ int repack_without_refs(struct ref_store *ref_store,
740736
}
741737

742738
/* 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;
744742
}
745743

746744
static int packed_init_db(struct ref_store *ref_store, struct strbuf *err)

0 commit comments

Comments
 (0)