Skip to content

Simplify git commands #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Simplify git commands
Signed-off-by: Ofir Petrushka <hatkyinc@gmail.com>
  • Loading branch information
ofir-petrushka committed Sep 7, 2020
commit e7aa88747cd28e737c0318cccfa0afccf1cf659d
3 changes: 1 addition & 2 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,7 @@ def with_custom_env_variables(&block)

def command(cmd, opts = [], chdir = true, redirect = '', &block)
global_opts = []
global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
global_opts << ["-C", "#{@git_work_dir}"] if !@git_work_dir.nil?
global_opts << ["-c", "color.ui=false"]

opts = [opts].flatten.map {|s| escape(s) }.join(' ')
Expand Down
4 changes: 2 additions & 2 deletions tests/units/test_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_logger
@git.branches.size

logc = File.read(log.path)
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
assert(/INFO -- : git '-C' '[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
assert(/DEBUG -- : diff_over_patches/.match(logc))

log = Tempfile.new('logfile')
Expand All @@ -31,7 +31,7 @@ def test_logger
@git.branches.size

logc = File.read(log.path)
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
assert(/INFO -- : git '-C' '[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
assert(!/DEBUG -- : diff_over_patches/.match(logc))
end

Expand Down