Fix git promisor fetch authorization failure with partial clones #5244
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.
Problem
When using partial clones with
fetchFilter: blob:none
, git checkout operations fail during promisor fetches with authorization errors:This occurs because git's automatic promisor fetches (used to retrieve missing objects in partial clones) don't inherit the authorization headers that were passed as command-line arguments to the main git operations.
Root Cause
The current implementation only passes authentication as command line arguments (
-c http.extraheader=...
) to explicit git commands like fetch and checkout. However, git's internal promisor fetches are separate operations that don't inherit these command line configurations and need the authentication to be available in git config.Solution
When partial clones are detected (presence of fetch filters), the authentication headers are now set up in git config using
gitCommandManager.GitConfig()
. This ensures that all git operations, including automatic promisor fetches, have access to the authentication credentials.Key Changes
GitSourceProvider.cs
to detect when fetch filters are being used and set up authentication in git configconfigModifications
dictionary for proper cleanup via existing mechanismsHow it works
Testing
Added comprehensive unit test
TestPartialCloneAuthenticationConfigSetup
that verifies git config authentication is properly set up when using partial clones. Enhanced theMockGitCliManager
to support testing git config operations.Impact
This change only affects scenarios where:
blob:none
)UseFetchFilterInCheckoutTask
knob is enabledThe fix is backward compatible and doesn't impact existing git operations that don't use partial clones.
Fixes #5143.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
03nvsblobprodwcus014.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)055vsblobprodwcus02.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)1g1vsblobprodwcus01.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)3eavsblobprodwcus03.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)3zgvsblobprodwcus024.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)40qvsblobprodwcus022.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)4fdvsblobprodwcus012.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)5tbvsblobprodwcus06.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)61cvsblobprodwcus010.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)73dvsblobprodwcus07.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)8usvsblobprodwcus011.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)9owvsblobprodwcus020.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)arpvsblobprodwcus017.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)crcvsblobprodwcus021.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)fslvsblobprodwcus015.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)uubvsblobprodwcus018.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)vwmvsblobprodwcus016.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)xg1vsblobprodwcus019.vsblob.vsassets.io
dotnet build --configuration Release -p:PackageRuntime=linux-x64
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.