Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Agent.Plugins/GitSourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,16 @@ public async Task GetSourceAsync(
}
}

if (File.Exists(Path.Combine(targetPath, ".autoManagedVhd"))
string agentWorkFolder = executionContext.Variables.GetValueOrDefault("agent.workfolder")?.Value;
if (!string.IsNullOrEmpty(agentWorkFolder)
&& File.Exists(Path.Combine(agentWorkFolder, ".autoManagedVhd"))
&& !AgentKnobs.DisableAutoManagedVhdShallowOverride.GetValue(executionContext).AsBoolean())
{
// The existing working directory comes from an auto-managed VHD and is a full,
// non-shallow clone of the repository. Some pipelines enable shallow fetch, but
// Git cannot convert an existing full clone into a shallow one in-place.
// The existing working directory comes from an AutoManagedVHD (indicated by the
// .autoManagedVhd marker file placed in the agent work folder).
// An AutoManagedVHD always contains a full, non-shallow clone of the repository.
// Some pipelines enable shallow fetch parameters (e.g., fetchDepth > 0). However,
// Git cannot convert an existing full clone into a shallow one in-place.
//
// Technical reason:
// A full clone already has complete commit history and object reachability.
Expand Down
Loading