зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
f3f9724940
Коммит
0f199b1ee0
|
@ -1621,19 +1621,19 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
|
|||
*
|
||||
* The refs in 'refnames' needn't be sorted. `err` must not be NULL.
|
||||
*/
|
||||
static int repack_without_refs(struct files_ref_store *refs,
|
||||
static int repack_without_refs(struct packed_ref_store *refs,
|
||||
struct string_list *refnames, struct strbuf *err)
|
||||
{
|
||||
struct ref_dir *packed;
|
||||
struct string_list_item *refname;
|
||||
int ret, needs_repacking = 0, removed = 0;
|
||||
|
||||
files_assert_main_repository(refs, "repack_without_refs");
|
||||
packed_assert_main_repository(refs, "repack_without_refs");
|
||||
assert(err);
|
||||
|
||||
/* Look for a packed ref */
|
||||
for_each_string_list_item(refname, refnames) {
|
||||
if (get_packed_ref(refs->packed_ref_store, refname->string)) {
|
||||
if (get_packed_ref(refs, refname->string)) {
|
||||
needs_repacking = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -1643,11 +1643,11 @@ static int repack_without_refs(struct files_ref_store *refs,
|
|||
if (!needs_repacking)
|
||||
return 0; /* no refname exists in packed refs */
|
||||
|
||||
if (lock_packed_refs(refs->packed_ref_store, 0)) {
|
||||
unable_to_lock_message(refs->packed_ref_store->path, errno, err);
|
||||
if (lock_packed_refs(refs, 0)) {
|
||||
unable_to_lock_message(refs->path, errno, err);
|
||||
return -1;
|
||||
}
|
||||
packed = get_packed_refs(refs->packed_ref_store);
|
||||
packed = get_packed_refs(refs);
|
||||
|
||||
/* Remove refnames from the cache */
|
||||
for_each_string_list_item(refname, refnames)
|
||||
|
@ -1658,12 +1658,12 @@ static int repack_without_refs(struct files_ref_store *refs,
|
|||
* All packed entries disappeared while we were
|
||||
* acquiring the lock.
|
||||
*/
|
||||
rollback_packed_refs(refs->packed_ref_store);
|
||||
rollback_packed_refs(refs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write what remains */
|
||||
ret = commit_packed_refs(refs->packed_ref_store);
|
||||
ret = commit_packed_refs(refs);
|
||||
if (ret)
|
||||
strbuf_addf(err, "unable to overwrite old ref-pack file: %s",
|
||||
strerror(errno));
|
||||
|
@ -1681,7 +1681,7 @@ static int files_delete_refs(struct ref_store *ref_store, const char *msg,
|
|||
if (!refnames->nr)
|
||||
return 0;
|
||||
|
||||
result = repack_without_refs(refs, refnames, &err);
|
||||
result = repack_without_refs(refs->packed_ref_store, refnames, &err);
|
||||
if (result) {
|
||||
/*
|
||||
* If we failed to rewrite the packed-refs file, then
|
||||
|
@ -3101,7 +3101,7 @@ static int files_transaction_finish(struct ref_store *ref_store,
|
|||
}
|
||||
}
|
||||
|
||||
if (repack_without_refs(refs, &refs_to_delete, err)) {
|
||||
if (repack_without_refs(refs->packed_ref_store, &refs_to_delete, err)) {
|
||||
ret = TRANSACTION_GENERIC_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче