Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Git env config
# If you need to use a custom SSH script
config.git_ssh = '/path/to/ssh/script'
end

```

_NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_

Here are the operations that need read permission only.

Expand Down
2 changes: 1 addition & 1 deletion lib/git/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize
end

def binary_path
@binary_path || 'git'
@binary_path || ENV['GIT_PATH'] && File.join(ENV['GIT_PATH'], 'git') || 'git'
end

def git_ssh
Expand Down
6 changes: 6 additions & 0 deletions tests/units/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ def test_set_config
def test_env_config
with_custom_env_variables do
begin
assert_equal(Git::Base.config.binary_path, 'git')
assert_equal(Git::Base.config.git_ssh, nil)

ENV['GIT_PATH'] = '/env/bin'
ENV['GIT_SSH'] = '/env/git/ssh'

assert_equal(Git::Base.config.binary_path, '/env/bin/git')
assert_equal(Git::Base.config.git_ssh, '/env/git/ssh')

Git.configure do |config|
config.binary_path = '/usr/bin/git'
config.git_ssh = '/path/to/ssh/script'
end

assert_equal(Git::Base.config.binary_path, '/usr/bin/git')
assert_equal(Git::Base.config.git_ssh, '/path/to/ssh/script')

@git.log
ensure
ENV['GIT_SSH'] = nil
ENV['GIT_PATH'] = nil

Git.configure do |config|
config.binary_path = nil
Expand Down