fix: apply insteadOf from global config for detached remotes #7195
+70
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Detached remotes already read global/system config for http proxy
settings, but did not apply
url.*.insteadOforurl.*.pushInsteadOfrules. This inconsistency meant that
git_remote_create_detachedbehaved differently from git's
ls-remote, which was the primaryuse 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 restorethe 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_typeexposed 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.