Skip to content

Commit e7aa887

Browse files
Simplify git commands
Signed-off-by: Ofir Petrushka <hatkyinc@gmail.com>
1 parent d1908f6 commit e7aa887

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/git/lib.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,7 @@ def with_custom_env_variables(&block)
993993

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

1000999
opts = [opts].flatten.map {|s| escape(s) }.join(' ')

tests/units/test_logger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_logger
1919
@git.branches.size
2020

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

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

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

0 commit comments

Comments
 (0)