fix: apply insteadOf from global config for detached remotes#7195
Open
weihanglo wants to merge 2 commits intolibgit2:mainfrom
Open
fix: apply insteadOf from global config for detached remotes#7195weihanglo wants to merge 2 commits intolibgit2:mainfrom
weihanglo wants to merge 2 commits intolibgit2:mainfrom
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.