Skip to content

Commit 93d23b1

Browse files
committed
(fix): only disable cone mode for subdirectory checkouts
1 parent 3d2f98d commit 93d23b1

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,21 +857,30 @@ public function generateCloneCommand(string $owner, string $repositoryName, stri
857857
$directory = escapeshellarg($directory);
858858
$rootDirectory = escapeshellarg($rootDirectory);
859859

860+
$isSubdirectory = $rootDirectory !== escapeshellarg('*');
861+
860862
$commands = [
861863
"mkdir -p {$directory}",
862864
"cd {$directory}",
863865
"git config --global init.defaultBranch main",
864866
"git init",
865867
"git remote add origin {$cloneUrl}",
866-
// Enable non-cone sparse checkout (cone mode includes root-level files)
868+
// Enable sparse checkout
867869
"git config core.sparseCheckout true",
868-
"git config core.sparseCheckoutCone false",
870+
];
871+
872+
// Disable cone mode for subdirectory checkouts (cone mode includes root-level files)
873+
if ($isSubdirectory) {
874+
$commands[] = "git config core.sparseCheckoutCone false";
875+
}
876+
877+
$commands = array_merge($commands, [
869878
"echo {$rootDirectory} >> .git/info/sparse-checkout",
870879
// Disable fetching of refs we don't need
871880
"git config --add remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'",
872881
// Disable fetching of tags
873882
"git config remote.origin.tagopt --no-tags",
874-
];
883+
]);
875884

876885
switch ($versionType) {
877886
case self::CLONE_TYPE_BRANCH:

0 commit comments

Comments
 (0)