repack_without_refs(): take a `packed_ref_store *` parameter
It only cares about the packed-refs part of the reference store. 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
0f199b1ee051e3e6854268841335287c3ad94b88
1 file changed
+10
-10
refs/files-backend.c
+10
-10
@@ -1621,19 +1621,19 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
1621
*
1622
* The refs in 'refnames' needn't be sorted. `err` must not be NULL.
1623
*/
1624
-static int repack_without_refs(struct files_ref_store *refs,
1624
+static int repack_without_refs(struct packed_ref_store *refs,
1625
struct string_list *refnames, struct strbuf *err)
1626
{
1627
struct ref_dir *packed;
1628
struct string_list_item *refname;
1629
int ret, needs_repacking = 0, removed = 0;
1630
1631
- files_assert_main_repository(refs, "repack_without_refs");
1631
+ packed_assert_main_repository(refs, "repack_without_refs");
1632
assert(err);
1633
1634
/* Look for a packed ref */
1635
for_each_string_list_item(refname, refnames) {
1636
- if (get_packed_ref(refs->packed_ref_store, refname->string)) {
1636
+ if (get_packed_ref(refs, refname->string)) {
1637
needs_repacking = 1;
1638
break;
1639
}
@@ -1643,11 +1643,11 @@ static int repack_without_refs(struct files_ref_store *refs,
1643
if (!needs_repacking)
1644
return 0; /* no refname exists in packed refs */
1645
1646
- if (lock_packed_refs(refs->packed_ref_store, 0)) {
1647
- unable_to_lock_message(refs->packed_ref_store->path, errno, err);
1646
+ if (lock_packed_refs(refs, 0)) {
1647
+ unable_to_lock_message(refs->path, errno, err);
1648
return -1;
1649
}
1650
- packed = get_packed_refs(refs->packed_ref_store);
1650
+ packed = get_packed_refs(refs);
1651
1652
/* Remove refnames from the cache */
1653
for_each_string_list_item(refname, refnames)
@@ -1658,12 +1658,12 @@ static int repack_without_refs(struct files_ref_store *refs,
1658
* All packed entries disappeared while we were
1659
* acquiring the lock.
1660
*/
1661
- rollback_packed_refs(refs->packed_ref_store);
1661
+ rollback_packed_refs(refs);
1662
return 0;
1663
}
1664
1665
/* Write what remains */
1666
- ret = commit_packed_refs(refs->packed_ref_store);
1666
+ ret = commit_packed_refs(refs);
1667
if (ret)
1668
strbuf_addf(err, "unable to overwrite old ref-pack file: %s",
1669
strerror(errno));
@@ -1681,7 +1681,7 @@ static int files_delete_refs(struct ref_store *ref_store, const char *msg,
1681
if (!refnames->nr)
1682
return 0;
1683
1684
- result = repack_without_refs(refs, refnames, &err);
1684
+ result = repack_without_refs(refs->packed_ref_store, refnames, &err);
1685
if (result) {
1686
/*
1687
* If we failed to rewrite the packed-refs file, then
@@ -3101,7 +3101,7 @@ static int files_transaction_finish(struct ref_store *ref_store,
3101
}
3102
}
3103
3104
- if (repack_without_refs(refs, &refs_to_delete, err)) {
3104
+ if (repack_without_refs(refs->packed_ref_store, &refs_to_delete, err)) {
3105
ret = TRANSACTION_GENERIC_ERROR;
3106
goto cleanup;
3107
}