Skip to content

Commit 5f80bd7

Browse files
authored
Enable symlink support explicitly (#3406)
motivation: enable git symlink support for Windows changes: pass core.symlinks=true to git clone operations
1 parent 0b9c0d8 commit 5f80bd7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/SourceControl/GitRepository.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
8383
precondition(!localFileSystem.exists(path))
8484

8585
// FIXME: Ideally we should pass `--progress` here and report status regularly. We currently don't have callbacks for that.
86-
try self.callGit("clone", "--mirror", repository.url, path.pathString,
86+
//
87+
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
88+
try self.callGit("clone", "-c", "core.symlinks=true", "--mirror", repository.url, path.pathString,
8789
repository: repository,
8890
failureMessage: "Failed to clone repository \(repository.url)")
8991
}
@@ -118,7 +120,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
118120
// For editable clones, i.e. the user is expected to directly work on them, first we create
119121
// a clone from our cache of repositories and then we replace the remote to the one originally
120122
// present in the bare repository.
121-
try self.callGit("clone", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
123+
//
124+
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
125+
try self.callGit("clone", "-c", "core.symlinks=true", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
122126
repository: repository,
123127
failureMessage: "Failed to clone repository \(repository.url)")
124128
// The default name of the remote.
@@ -138,7 +142,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
138142
// re-resolve such that the objects in this repository changed, we would
139143
// only ever expect to get back a revision that remains present in the
140144
// object storage.
141-
try self.callGit("clone", "--shared", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
145+
//
146+
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
147+
try self.callGit("clone", "-c", "core.symlinks=true", "--shared", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
142148
repository: repository,
143149
failureMessage: "Failed to clone repository \(repository.url)")
144150
}

0 commit comments

Comments
 (0)