Skip to content

Conversation

@weihanglo
Copy link
Contributor

@weihanglo weihanglo commented Jan 14, 2026

Detached remotes already read global/system config for http proxy
settings, but did not apply url.*.insteadOf or url.*.pushInsteadOf
rules. This inconsistency meant that git_remote_create_detached
behaved differently from git's ls-remote, which was the primary
use case for detached remotes.

This fixes it by loading the default config when no repository is
provided and apply insteadOf rules consistently.

While this is a behavior change, it still respects
GIT_REMOTE_CREATE_SKIP_INSTEADOF, meaning that user can restore
the previous behavior with minimal effort

Fixes #5469

How to review

Best review commit by commit.

The first commit shows the current behavior.
The test diff in the second commit demonstrates the behavior change.


This was found during the Cargo integration with SHA256.

I was trying detached remote to probe the remote object format first (via git_remote_oid_type exposed by #7185), and then set up the repository. Cargo needs to probe first because it stores sha256/sha1 separately for backward compatibility. However detached remote not respecting insteadOf may lead to inconsistent behavior.

`git_remote_create_detached` does not apply
`url.*.insteadOf` or url.*.pushInsteadOf from global config.

These tests currently pass, asserting the buggy behavior
and serving as a minimal reproduction.

The assertions will be updated when the fix is applied.

See <libgit2#5469>
Detached remotes already read global/system config for http proxy
settings, but did not apply url.*.insteadOf or url.*.pushInsteadOf
rules. This inconsistency meant that `git_remote_create_detached`
behaved differently from git's `ls-remote`, which was the primary
use case for detached remotes.

This fixes it by loading the default config when no repository is
provided and apply insteadOf rules consistently.

While this is a behavior change, it still respects
`GIT_REMOTE_CREATE_SKIP_INSTEADOF`, meaning that user can restore
the previous behavior with minimal effort

Fixes libgit2#5469
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.

git_remote_create_detached will not apply the insteadOf from global config

1 participant