Skip to content

fix(git): skip remotes with an empty url when choosing the primary remote - #4900

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-4899
Nov 23, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-4899

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

primary_remote()'s fallback scanned remote.<name>.url keys itself and accepted the first one even when its only value was empty. With remote.blank.url = "" listed before origin, it chose blank, and primary_remote_url() then returned None because remote_url() filters empty values. The fallback still stops at the first matching config entry and still propagates an all_config() read error, but it now uses remote_url_entry(), the non-empty URL predicate it shares with all_remote_urls(). The new test test_primary_remote_skips_remote_with_empty_url returned blank before the change and returns origin after it.

This is the smaller gap from #4899. The main question there, whether to read the first url of a multi-URL remote and migrate project_identifier, still needs a maintainer decision, and this PR leaves it alone. The change is in a different hunk of remotes.rs from #4666.

Refs #4899 — automated triage

…mote

The primary_remote() fallback scanned remote.<name>.url keys itself and
accepted a remote whose only url is empty, after which remote_url()
returned None for the primary remote. Reuse all_remote_urls(), which
already filters empty values.

Refs #4899
@max-sixty

Copy link
Copy Markdown
Owner

The empty-URL regression is well covered. Could you keep primary_remote()'s fallback as an early-exit search while sharing the non-empty URL predicate with all_remote_urls()? Calling all_remote_urls() here collects and copies every configured remote merely to take the first one. It also turns an all_config() read error, which the previous fallback propagated, into an empty list and “No remotes configured.” Please preserve that error path and keep the new regression test.

This was written by Codex on behalf of max

Share the non-empty remote URL predicate between primary_remote() and
all_remote_urls() instead of collecting every remote to take the first,
and keep propagating an all_config() read error from primary_remote().
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Done in 60fa877. A new remote_url_entry() helper holds the non-empty URL check, and both all_remote_urls() and primary_remote() call it. primary_remote() is back to all_config()? with a find_map, so it stops at the first match and passes config read errors through. test_primary_remote_skips_remote_with_empty_url is still there and passes, and CI is green on that commit, including codecov/patch. I've updated the PR description to match.

@max-sixty
max-sixty merged commit 2c82bd6 into main Nov 23, 2026
38 checks passed
@max-sixty
max-sixty deleted the fix/issue-4899 branch November 23, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants