Call Git cmd_main directly
This commit is contained in:
@@ -54,6 +54,10 @@ internal class GitProcessRunner(
|
||||
arguments: List<String>,
|
||||
environment: Map<String, String> = emptyMap(),
|
||||
): ProcessExecutionResult {
|
||||
if (context != null) {
|
||||
gitExecDirectory(binary)
|
||||
return NativeGitBridge.runGitMain(binary, workingDir, arguments, gitEnvironment(binary, workingDir, environment))
|
||||
}
|
||||
return runProcess(binary, workingDir, arguments, environment)
|
||||
}
|
||||
|
||||
@@ -88,19 +92,7 @@ internal class GitProcessRunner(
|
||||
.directory(workingDir)
|
||||
.redirectErrorStream(true)
|
||||
.apply {
|
||||
environment()["HOME"] = workingDir.absolutePath
|
||||
environment()["GIT_EXEC_PATH"] = gitExecPath.absolutePath
|
||||
environment()["PATH"] = listOfNotNull(
|
||||
gitExecPath.absolutePath,
|
||||
System.getenv("PATH")?.takeIf { it.isNotBlank() },
|
||||
).joinToString(File.pathSeparator)
|
||||
environment()["GIT_CONFIG_NOSYSTEM"] = "1"
|
||||
environment()["GIT_AUTHOR_NAME"] = "GitHug"
|
||||
environment()["GIT_AUTHOR_EMAIL"] = "githug@example.com"
|
||||
environment()["GIT_COMMITTER_NAME"] = "GitHug"
|
||||
environment()["GIT_COMMITTER_EMAIL"] = "githug@example.com"
|
||||
environment()["LC_ALL"] = "C"
|
||||
environment().putAll(extraEnvironment)
|
||||
environment().putAll(gitEnvironment(binary, workingDir, extraEnvironment, gitExecPath))
|
||||
}
|
||||
.start()
|
||||
|
||||
@@ -137,6 +129,32 @@ internal class GitProcessRunner(
|
||||
return directory
|
||||
}
|
||||
|
||||
private fun gitEnvironment(
|
||||
binary: File,
|
||||
workingDir: File,
|
||||
extraEnvironment: Map<String, String>,
|
||||
gitExecPath: File = gitExecDirectory(binary),
|
||||
): Map<String, String> {
|
||||
return buildMap {
|
||||
put("HOME", workingDir.absolutePath)
|
||||
put("GIT_EXEC_PATH", gitExecPath.absolutePath)
|
||||
put(
|
||||
"PATH",
|
||||
listOfNotNull(
|
||||
gitExecPath.absolutePath,
|
||||
System.getenv("PATH")?.takeIf { it.isNotBlank() },
|
||||
).joinToString(File.pathSeparator),
|
||||
)
|
||||
put("GIT_CONFIG_NOSYSTEM", "1")
|
||||
put("GIT_AUTHOR_NAME", "GitHug")
|
||||
put("GIT_AUTHOR_EMAIL", "githug@example.com")
|
||||
put("GIT_COMMITTER_NAME", "GitHug")
|
||||
put("GIT_COMMITTER_EMAIL", "githug@example.com")
|
||||
put("LC_ALL", "C")
|
||||
putAll(extraEnvironment)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshGitExecDirectoryIfNeeded(directory: File, binary: File) {
|
||||
val fingerprint = buildString {
|
||||
append(binary.absolutePath)
|
||||
@@ -161,7 +179,6 @@ internal class GitProcessRunner(
|
||||
if (context != null) {
|
||||
try {
|
||||
Os.symlink(binary.absolutePath, alias.absolutePath)
|
||||
alias.setExecutable(true, false)
|
||||
return
|
||||
} catch (_: Exception) {
|
||||
// Fall through to the portable options below.
|
||||
|
||||
Reference in New Issue
Block a user