From 07e582078e3b647fd9cfad76a70494d288faf3b4 Mon Sep 17 00:00:00 2001 From: Jacob Bijsterbosch Date: Tue, 7 Apr 2026 12:28:59 +0200 Subject: [PATCH 1/2] Fix stderr redirections for git commands on Windows --- bin/GitUtility.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/GitUtility.rb b/bin/GitUtility.rb index 35576a8..3ecf1a1 100644 --- a/bin/GitUtility.rb +++ b/bin/GitUtility.rb @@ -31,6 +31,11 @@ def self.get_git_has_uncommitted_changes(path) return run_git(path, 'status --porcelain') != nil end + # Shell stderr redirect for discarding git noise: cmd.exe has no /dev/null (use 2>nul); Unix uses 2>/dev/null. + def self.git_stderr_null + return (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) ? '2>nul' : '2>/dev/null' + end + # Runs a git command from the directory of path. # Returns trimmed output as string, or nil on empty output / error. def self.run_git(path, args) @@ -38,7 +43,7 @@ def self.run_git(path, args) dir = File.directory?(path) ? path : File.dirname(path) curr_dir = Dir.pwd Dir.chdir(dir) - cmd = ($git_bin_path.to_s.empty? ? 'git' : "\"#{$git_bin_path}git\"") + ' ' + args + ' 2>/dev/null' + cmd = ($git_bin_path.to_s.empty? ? 'git' : "\"#{$git_bin_path}git\"") + ' ' + args + ' ' + git_stderr_null socket = IO.popen(cmd) begin out = socket.gets(nil).to_s.strip @@ -52,5 +57,5 @@ def self.run_git(path, args) return nil end - private_class_method :run_git + private_class_method :git_stderr_null, :run_git end From 336d2d0012c70de707052a7cd922599128eb166a Mon Sep 17 00:00:00 2001 From: Jacob Bijsterbosch Date: Tue, 7 Apr 2026 15:30:28 +0200 Subject: [PATCH 2/2] Fix mixing string interpolation and concatenation --- bin/GitUtility.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/GitUtility.rb b/bin/GitUtility.rb index 3ecf1a1..86d4fe5 100644 --- a/bin/GitUtility.rb +++ b/bin/GitUtility.rb @@ -31,11 +31,16 @@ def self.get_git_has_uncommitted_changes(path) return run_git(path, 'status --porcelain') != nil end + # Git executable for shell invocation: PATH name or quoted path when $git_bin_path is set. + def self.git_exe + return $git_bin_path.to_s.empty? ? 'git' : "\"#{$git_bin_path}git\"" + end + # Shell stderr redirect for discarding git noise: cmd.exe has no /dev/null (use 2>nul); Unix uses 2>/dev/null. def self.git_stderr_null return (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) ? '2>nul' : '2>/dev/null' end - + # Runs a git command from the directory of path. # Returns trimmed output as string, or nil on empty output / error. def self.run_git(path, args) @@ -43,7 +48,7 @@ def self.run_git(path, args) dir = File.directory?(path) ? path : File.dirname(path) curr_dir = Dir.pwd Dir.chdir(dir) - cmd = ($git_bin_path.to_s.empty? ? 'git' : "\"#{$git_bin_path}git\"") + ' ' + args + ' ' + git_stderr_null + cmd = "#{git_exe} #{args} #{git_stderr_null}" socket = IO.popen(cmd) begin out = socket.gets(nil).to_s.strip @@ -57,5 +62,5 @@ def self.run_git(path, args) return nil end - private_class_method :git_stderr_null, :run_git + private_class_method :git_exe, :git_stderr_null, :run_git end