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"]))
1821to bypass the parsing of the command string.
1922"""
2023function 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
5069end
5170
5271function git (args:: AbstractVector{<:AbstractString} ; kwargs... )
0 commit comments