Skip to content

remote: use configured remote names when the URL is empty - #7477

Closed
hakarrr wants to merge 16 commits into
libgit2:mainfrom
hakarrr:remote-name-url-fallback
Closed

hakarrr wants to merge 16 commits into
libgit2:mainfrom
hakarrr:remote-name-url-fallback

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 11, 2026

Copy link
Copy Markdown

A configured remote with no URL currently either fails lookup or returns a
NULL URL. Git uses the remote's name in both cases. Follow that behavior,
including URL rewrites and an explicit push URL, while still returning
GIT_ENOTFOUND when the remote has no configuration.

Recognize remotes with settings other than URL/pushURL in lookup and listing.
This also means creating a remote over an existing prune-only configuration
returns GIT_EEXISTS, as Git does. Update the prune test to load its configured
remote instead of recreating it.

Reject a bare URL/pushURL setting with no value instead of confusing it with
an explicit empty value. Add lookup, rewrite, list, local connection and
rename/set-url/delete coverage; document the fallback.

Fixes #7028

Validation:

  • Built current Git 1891de46 and checked missing/empty URL, push-only,
    rewrite, explicit pushURL and missing-remote behavior.
  • Focused remote suites: 57 tests pass (network::remote::remotes 40,
    remote::list 2, network::fetchlocal 15).
  • Native Debug offline selection: 3073 pass, 44 skip, 0 fail.
  • GCC 11.4 -Werror with ASan/UBSan and leak detection: 7 remote suites
    (125 tests) clean; offline selection 3073 pass, 43 skip, 0 fail, 0 sanitizer
    reports.
  • Offline selection excludes online and clone::nonetwork. Both builds exclude
    core::structinit, whose padding comparison fails on unchanged baseline.
    Sanitizer selection additionally excludes pack::threadsafety: the unexcluded
    run reports 8848 bytes / 75 allocations leaked, identically reproduced on
    baseline.
  • Linux x86_64 only; HTTPS/SSH/NTLM unavailable and disabled.

Known differences from Git:

  • A bare, value-less url/pushURL entry makes lookup fail with a generic
    invalid-argument error where Git exits with a config error; both reject it.
  • git_remote_list still lists a remote whose url entry has no value; Git's
    git remote fails the whole config read in that case.
  • A multi-valued url keeps last-value-wins (pre-existing behavior, unchanged).

hakarrr and others added 16 commits November 11, 2026 13:51
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…d in next commit)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…ewed replacement

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…d name, renamed in next commit)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…oper path)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…reviewed replacement

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…fixed name, renamed in next commit)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…ath)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…placement

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
… renamed in next commit)

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Author

Could a maintainer review this PR and let me know if the approach is wanted? Please point out any changes or additional evidence needed before it can move forward. Thanks.

@hakarrr

hakarrr commented Nov 16, 2026

Copy link
Copy Markdown
Author

One more follow-up on this. Please let me know if there's a preferred next step, or if anything in the change needs rework - glad to iterate.

@hakarrr

hakarrr commented Nov 20, 2026

Copy link
Copy Markdown
Author

Could a maintainer share whether this change is still wanted and what, if anything, is needed before review? I also have #7476 and #7475 open; keeping the follow-up here rather than posting on all three. Please let me know if any should take a different direction. Thanks.

@hakarrr hakarrr closed this Nov 25, 2026
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.

Unset or empty remote URL behavior does not match with git CLI

1 participant