Skip to content

Commit 5229752

Browse files
authored
SourceControl: adjust file path handling (#5485)
Use `AbsolutePath` more aggressively for building paths and file system names. This enables the file processing to work properly on Windows as well.
1 parent a802f69 commit 5229752

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/SourceControl/GitRepository.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,11 @@ private class GitFileSystemView: FileSystem {
780780
private func getEntry(_ path: AbsolutePath) throws -> Tree.Entry? {
781781
// Walk the components resolving the tree (starting with a synthetic
782782
// root entry).
783-
var current: Tree.Entry = Tree.Entry(location: self.root, type: .tree, name: "/")
783+
var current: Tree.Entry = Tree.Entry(location: self.root, type: .tree, name: AbsolutePath.root.pathString)
784784
var currentPath = AbsolutePath.root
785-
for component in path.components.dropFirst(1) {
785+
for component in path.components {
786786
// Skip the root pseudo-component.
787-
if component == "/" { continue }
787+
if component == AbsolutePath.root.pathString { continue }
788788

789789
currentPath = currentPath.appending(component: component)
790790
// We have a component to resolve, so the current entry must be a tree.
@@ -877,7 +877,7 @@ private class GitFileSystemView: FileSystem {
877877
}
878878

879879
public var currentWorkingDirectory: AbsolutePath? {
880-
return AbsolutePath("/")
880+
return AbsolutePath.root
881881
}
882882

883883
func changeCurrentWorkingDirectory(to path: AbsolutePath) throws {

0 commit comments

Comments
 (0)