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

Commit ad8e37e

Browse files
committed
Change the way we search for git-lfs if there's a custom git path
If there's a custom git path but not a custom git-lfs path, assume that git-lfs is in the directory where we would extract if from the bundle and look there directly instead of going recursively in the file system, it's most likely there.
1 parent a61a4ce commit ad8e37e

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,16 @@ public GitInstallationState VerifyGitSettings(GitInstallationState state = null)
6767
if (state.GitIsValid)
6868
state.GitInstallationPath = state.GitExecutablePath.Parent.Parent;
6969

70-
var isDefaultGitLfs = !state.GitLfsExecutablePath.IsInitialized;
71-
if (isDefaultGitLfs)
70+
if (!state.GitLfsExecutablePath.IsInitialized)
7271
{
73-
state.GitLfsExecutablePath = ProcessManager.FindExecutableInPath(installDetails.GitLfsExecutable, false, state.GitExecutablePath.Parent);
74-
if (!state.GitLfsExecutablePath.IsInitialized)
75-
state.GitLfsExecutablePath = ProcessManager.FindExecutableInPath(installDetails.GitLfsExecutable, true, state.GitInstallationPath);
72+
// look for it in the directory where we would install it from the bundle
73+
state.GitLfsExecutablePath = installDetails.GitLfsExecutablePath;
7674
}
7775

7876
state = ValidateGitLfsVersion(state);
7977

8078
if (state.GitLfsIsValid)
81-
{
82-
if (isDefaultGitLfs)
83-
state.GitLfsInstallationPath = state.GitInstallationPath;
84-
else
85-
state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
86-
}
79+
state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
8780

8881
return state;
8982
}
@@ -111,7 +104,7 @@ public GitInstallationState FindSystemGit(GitInstallationState state)
111104
state.GitLfsExecutablePath = gitLfsPath;
112105
state = ValidateGitLfsVersion(state);
113106
if (state.GitLfsIsValid)
114-
state.GitLfsInstallationPath = gitLfsPath.Parent;
107+
state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
115108
}
116109
return state;
117110
}
@@ -128,10 +121,7 @@ public GitInstallationState SetDefaultPaths(GitInstallationState state)
128121
if (!state.GitLfsIsValid)
129122
{
130123
state.GitLfsExecutablePath = installDetails.GitLfsExecutablePath;
131-
if (state.GitIsValid && state.GitInstallationPath != installDetails.GitInstallationPath)
132-
state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
133-
else
134-
state.GitLfsInstallationPath = installDetails.GitInstallationPath;
124+
state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
135125
state = ValidateGitLfsVersion(state);
136126
}
137127
return state;

src/GitHub.Api/Platform/ProcessEnvironment.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
3737
var pathEntries = new List<string>();
3838
string separator = Environment.IsWindows ? ";" : ":";
3939

40+
NPath libexecPath = NPath.Default;
4041
if (Environment.GitInstallPath.IsInitialized)
4142
{
4243
var gitPathRoot = Environment.GitExecutablePath.Resolve().Parent.Parent;
@@ -53,9 +54,9 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
5354
binPath = baseExecPath.Combine("bin");
5455
}
5556

56-
var execPath = baseExecPath.Combine("libexec", "git-core");
57-
if (!execPath.DirectoryExists())
58-
execPath = NPath.Default;
57+
libexecPath = baseExecPath.Combine("libexec", "git-core");
58+
if (!libexecPath.DirectoryExists())
59+
libexecPath = NPath.Default;
5960

6061
if (Environment.IsWindows)
6162
{
@@ -66,17 +67,17 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
6667
pathEntries.Add(gitExecutableDir.ToString());
6768
}
6869

69-
if (execPath.IsInitialized)
70-
pathEntries.Add(execPath);
70+
if (libexecPath.IsInitialized)
71+
pathEntries.Add(libexecPath);
7172
pathEntries.Add(binPath);
7273

7374
// we can only set this env var if there is a libexec/git-core. git will bypass internally bundled tools if this env var
7475
// is set, which will break Apple's system git on certain tools (like osx-credentialmanager)
75-
if (execPath.IsInitialized)
76-
psi.EnvironmentVariables["GIT_EXEC_PATH"] = execPath.ToString();
76+
if (libexecPath.IsInitialized)
77+
psi.EnvironmentVariables["GIT_EXEC_PATH"] = libexecPath.ToString();
7778
}
7879

79-
if (Environment.GitLfsInstallPath.IsInitialized && Environment.GitInstallPath != Environment.GitLfsInstallPath)
80+
if (Environment.GitLfsInstallPath.IsInitialized && libexecPath != Environment.GitLfsInstallPath)
8081
{
8182
pathEntries.Add(Environment.GitLfsInstallPath);
8283
}

0 commit comments

Comments
 (0)