Skip to content

fix: preserve multiple remote URLs#2698

Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
multi-remote-url
Draft

fix: preserve multiple remote URLs#2698
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
multi-remote-url

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Jul 6, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #2696

Summary

  • Preserve all configured remote.<name>.url and remote.<name>.pushUrl values in gix::Remote instead of collapsing to the most recent config value.
  • Add Remote::urls(Direction) for all effective URLs, while keeping Remote::url(Direction) as the singular API returning the first effective URL.
  • Match Git's singular/all behavior for multi-URL remotes, including empty reset markers, URL rewrite rules, push fallback rewrites, and save/reload behavior for layered config.

Git Baseline

Git 2.50.1 returns the first configured URL for git remote get-url origin, while git remote get-url --all origin returns all URLs in configuration order. The same first/all behavior applies for --push. For fetch URLs used as push fallbacks, Git applies matching pushInsteadOf rules before falling back to insteadOf; explicit pushUrl values use normal insteadOf rewrites.

Validation

  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix remote::save::save_as_to::inherited_urls_are_saved_with_reset_markers -- --exact
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix remote::save
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix repository::remote
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix
  • cargo clippy -p gix --all-targets -- -D warnings
  • cargo check -p gix --all-targets
  • cargo check -p gix --no-default-features --all-targets (passes with existing hex_to_id_sha1_only dead-code warning)
  • git diff --check
  • codex review --commit 2d25f4e44b7b42a52469f75d39c39f109fbbfe01 (no findings)
  • GitHub Actions checks on PR fix: preserve multiple remote URLs #2698 are passing for commit 2d25f4e44b7b42a52469f75d39c39f109fbbfe01.

@Byron Sebastian Thiel (Byron) force-pushed the multi-remote-url branch 7 times, most recently from 1669ee1 to 432f8da Compare July 6, 2026 13:53
Configured remotes can have multiple remote.<name>.url or remote.<name>.pushUrl values, but gix::Remote kept only one value because lookup used the singular config accessor. That meant the most recent config value won, while Git exposes every effective URL and uses the first one for the singular get-url form.

Add ordered URL storage to gix::Remote and expose Remote::urls(Direction) for all effective URLs. Keep Remote::url(Direction) as the singular compatibility API, now returning the first effective URL. Fetch URLs used as push fallbacks try pushInsteadOf first and then insteadOf, matching Git behavior.

The regression fixture records Git 2.50.1 behavior with git remote get-url: without --all it prints the first configured URL, and with --all it prints all configured URLs in order for both fetch and push.

Validation:
- cargo test -p gix --test gix repository::remote::find_remote::multiple_urls_are_preserved_in_order_and_single_url_matches_git_first_url
- cargo test -p gix --test gix repository::remote
- cargo test -p gix --test gix remote::
- cargo test -p gix --test gix
- cargo check -p gix --all-targets
- cargo check -p gix --no-default-features --all-targets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of support for multiple remote URLs

2 participants