From e944fd76c87cb1ade55dc883fa685f286d503024 Mon Sep 17 00:00:00 2001 From: Sascha Girrulat Date: Wed, 11 Sep 2019 11:20:37 +0200 Subject: [PATCH 1/2] Support different localized git messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git2svn sometimes parses the stdout of git commands but if the locale is not set to something like en_US it can't and fails with the following error: Running command: git branch --track "" "remotes/svn/" fatal: No se puede configurar el rastreo de información; el punto de partida 'remotes/svn/1.0' no es una rama. ******************************************************************** svn2git warning: Tracking remote SVN branches is deprecated. In a future release local branches will be created without tracking. If you must resync your branches, run: svn2git --rebase ******************************************************************** Running command: git checkout "" error: pathspec '' did not match any file(s) known to git. command failed: ... A comparable error for 'git config' will happend if a older version of git (< 1.7.4) will be used. It's never a good idea to parse messages from stdout in a special language but this simple fix parse the messages in the same manner and should support different languages. --- lib/svn2git/migration.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 4de8a9e..2c9d041 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -357,7 +357,7 @@ def fix_branches # Our --rebase option obviates the need for read-only tracked remotes, however. So, we'll # deprecate the old option, informing those relying on the old behavior that they should # use the newer --rebase otion. - if status =~ /Cannot setup tracking information/m + if status =~ /fatal:.+'#{branch}'.+/ @cannot_setup_tracking_information = true run_command(Svn2Git::Migration.checkout_svn_branch(branch)) else @@ -476,7 +476,7 @@ def git_config_command if @git_config_command.nil? status = run_command('git config --local --get user.name', false) - @git_config_command = if status =~ /unknown option/m + @git_config_command = if status =~ /error: .+\s.+git config \[.+/m 'git config' else 'git config --local' @@ -488,4 +488,3 @@ def git_config_command end end - From 0144b3bc1699b606e275f20cd51602edf4c3d5d9 Mon Sep 17 00:00:00 2001 From: Sascha Girrulat Date: Wed, 11 Sep 2019 13:32:50 +0200 Subject: [PATCH 2/2] Use global stdin instead of local variable The stdin bypass will use a local variable stdin instead of $stdin and it will result in the following error: Traceback (most recent call last): 2: from /usr/lib/ruby/vendor_ruby/svn2git/migration.rb:432:in `block (2 levels) in run_command' 1: from /usr/lib/ruby/vendor_ruby/svn2git/migration.rb:432:in `loop' /usr/lib/ruby/vendor_ruby/svn2git/migration.rb:438:in `block (3 levels) in run_command': undefined local variable or method `stdin' for # (NameError) Did you mean? String This fix should handle the error and uses the global stdin --- lib/svn2git/migration.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 2c9d041..eb38338 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -430,13 +430,17 @@ def run_command(cmd, exit_on_error=true, printout_output=false) # sub-process's stdin pipe. Thread.new do loop do - user_reply = @stdin_queue.pop + begin + user_reply = @stdin_queue.pop - # nil is our cue to stop looping (pun intended). - break if user_reply.nil? + # nil is our cue to stop looping (pun intended). + break if user_reply.nil? - stdin.puts user_reply - stdin.close + $stdin.puts user_reply + $stdin.close + rescue IOError + $stdout.print "No input requested.\n" + end end end