Skip to content

Commit 9c08053

Browse files
committed
Use ssh from OpenSSH_jll instead of relying on system one
1 parent fc28591 commit 9c08053

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
name = "Git"
22
uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
3+
version = "1.4.0"
34
authors = ["Dilum Aluthge", "contributors"]
4-
version = "1.3.1"
55

66
[deps]
77
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
8+
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
9+
OpenSSH_jll = "9bd350c2-7e96-507f-8002-3f2e150b4e1b"
810

911
[compat]
1012
Git_jll = "2.44"
1113
JLLWrappers = "1.1"
14+
OpenSSH_jll = "9, 10"
1215
julia = "1.6"
1316

1417
[extras]
15-
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
1618
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1719

1820
[targets]
19-
test = ["JLLWrappers", "Test"]
21+
test = ["Test"]

src/git_function.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using OpenSSH_jll: OpenSSH_jll
2+
using JLLWrappers: pathsep, LIBPATH_env
3+
14
"""
25
git()
36
@@ -18,8 +21,8 @@ julia> run(git(["clone", "https://github.com/JuliaRegistries/General"]))
1821
to bypass the parsing of the command string.
1922
"""
2023
function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
21-
@static if Sys.iswindows()
22-
return Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
24+
git_cmd = @static if Sys.iswindows()
25+
Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
2326
else
2427
root = Git_jll.artifact_dir
2528

@@ -45,8 +48,24 @@ function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
4548
end
4649

4750
original_cmd = Git_jll.git(; adjust_PATH, adjust_LIBPATH)::Cmd
48-
return addenv(original_cmd, env_mapping...)::Cmd
51+
addenv(original_cmd, env_mapping...)::Cmd
4952
end
53+
54+
# Use OpenSSH from the JLL: <https://github.com/JuliaVersionControl/Git.jl/issues/51>.
55+
if OpenSSH_jll.is_available()
56+
path = split(get(ENV, "PATH", ""), pathsep)
57+
libpath = split(get(ENV, LIBPATH_env, ""), pathsep)
58+
59+
path = vcat(dirname(OpenSSH_jll.ssh_path), path)
60+
libpath = vcat(OpenSSH_jll.LIBPATH_list, libpath)
61+
62+
unique!(filter!(!isempty, path))
63+
unique!(filter!(!isempty, libpath))
64+
65+
git_cmd = addenv(git_cmd, "PATH" => join(path, pathsep), LIBPATH_env => join(libpath, pathsep))
66+
end
67+
68+
return git_cmd
5069
end
5170

5271
function git(args::AbstractVector{<:AbstractString}; kwargs...)

0 commit comments

Comments
 (0)