diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-07-16 09:42:26 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-16 09:42:27 -0700 |
| commit | 7b625c2a3511ac89acd14ae4bcbbc471bd50cdbb (patch) | |
| tree | 30a8a15086959ebd9bc32ebc7bdd6c30b6e6e574 /builtin/fetch.c | |
| parent | The tenth batch (diff) | |
| parent | clean up interface for refs_warn_dangling_symrefs (diff) | |
| download | git-7b625c2a3511ac89acd14ae4bcbbc471bd50cdbb.tar.gz git-7b625c2a3511ac89acd14ae4bcbbc471bd50cdbb.zip | |
Merge branch 'ph/fetch-prune-optim'
"git fetch --prune" used to be O(n^2) expensive when there are many
refs, which has been corrected.
* ph/fetch-prune-optim:
clean up interface for refs_warn_dangling_symrefs
refs: remove old refs_warn_dangling_symref
fetch-prune: optimize dangling-ref reporting
Diffstat (limited to 'builtin/fetch.c')
| -rw-r--r-- | builtin/fetch.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index d231a669d7..87a0cca799 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1340,9 +1340,10 @@ static int prune_refs(struct display_state *display_state, int result = 0; struct ref *ref, *stale_refs = get_stale_heads(rs, ref_map); struct strbuf err = STRBUF_INIT; - const char *dangling_msg = dry_run - ? _(" (%s will become dangling)") - : _(" (%s has become dangling)"); + struct string_list refnames = STRING_LIST_INIT_NODUP; + + for (ref = stale_refs; ref; ref = ref->next) + string_list_append(&refnames, ref->name); if (!dry_run) { if (transaction) { @@ -1353,15 +1354,9 @@ static int prune_refs(struct display_state *display_state, goto cleanup; } } else { - struct string_list refnames = STRING_LIST_INIT_NODUP; - - for (ref = stale_refs; ref; ref = ref->next) - string_list_append(&refnames, ref->name); - result = refs_delete_refs(get_main_ref_store(the_repository), "fetch: prune", &refnames, 0); - string_list_clear(&refnames, 0); } } @@ -1373,12 +1368,14 @@ static int prune_refs(struct display_state *display_state, _("(none)"), ref->name, &ref->new_oid, &ref->old_oid, summary_width); - refs_warn_dangling_symref(get_main_ref_store(the_repository), - stderr, dangling_msg, ref->name); } + string_list_sort(&refnames); + refs_warn_dangling_symrefs(get_main_ref_store(the_repository), + stderr, " ", dry_run, &refnames); } cleanup: + string_list_clear(&refnames, 0); strbuf_release(&err); free_refs(stale_refs); return result; |
