Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit eac5791

Browse files
committed
Support git-worktree on History
1 parent 9a08719 commit eac5791

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,36 @@ public RepositoryPathConfiguration(NPath repositoryPath)
6969
RepositoryPath = repositoryPath;
7070

7171
DotGitPath = repositoryPath.Combine(".git");
72+
NPath CommonPath;
7273
if (DotGitPath.FileExists())
7374
{
7475
DotGitPath =
7576
DotGitPath.ReadAllLines()
7677
.Where(x => x.StartsWith("gitdir:"))
7778
.Select(x => x.Substring(7).Trim().ToNPath())
7879
.First();
80+
if (DotGitPath.Combine("commondir").FileExists())
81+
{
82+
CommonPath = DotGitPath.Combine("commondir").ReadAllLines()
83+
.Select(x => x.Trim().ToNPath())
84+
.First();
85+
CommonPath = DotGitPath.Combine(CommonPath);
86+
}
87+
else
88+
{
89+
CommonPath = DotGitPath;
90+
}
91+
}
92+
else
93+
{
94+
CommonPath = DotGitPath;
7995
}
8096

81-
BranchesPath = DotGitPath.Combine("refs", "heads");
82-
RemotesPath = DotGitPath.Combine("refs", "remotes");
97+
BranchesPath = CommonPath.Combine("refs", "heads");
98+
RemotesPath = CommonPath.Combine("refs", "remotes");
8399
DotGitIndex = DotGitPath.Combine("index");
84100
DotGitHead = DotGitPath.Combine("HEAD");
85-
DotGitConfig = DotGitPath.Combine("config");
101+
DotGitConfig = CommonPath.Combine("config");
86102
DotGitCommitEditMsg = DotGitPath.Combine("COMMIT_EDITMSG");
87103
}
88104

src/GitHub.Api/Platform/DefaultEnvironment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public void InitializeRepository(NPath? repositoryPath = null)
8989

9090
expectedRepositoryPath = repositoryPath != null ? repositoryPath.Value : UnityProjectPath;
9191

92-
if (!expectedRepositoryPath.DirectoryExists(".git"))
92+
if (!expectedRepositoryPath.Exists(".git"))
9393
{
94-
NPath reporoot = UnityProjectPath.RecursiveParents.FirstOrDefault(d => d.DirectoryExists(".git"));
94+
NPath reporoot = UnityProjectPath.RecursiveParents.FirstOrDefault(d => d.Exists(".git"));
9595
if (reporoot.IsInitialized)
9696
expectedRepositoryPath = reporoot;
9797
}
@@ -102,7 +102,7 @@ public void InitializeRepository(NPath? repositoryPath = null)
102102
}
103103

104104
FileSystem.SetCurrentDirectory(expectedRepositoryPath);
105-
if (expectedRepositoryPath.DirectoryExists(".git"))
105+
if (expectedRepositoryPath.Exists(".git"))
106106
{
107107
RepositoryPath = expectedRepositoryPath;
108108
Repository = new Repository(RepositoryPath, CacheContainer);

0 commit comments

Comments
 (0)