{"thread":{"id":"17341","subject":"[PATCH] git-svn: Don't fail `--help' if git directory not found.","startedAt":"2009-01-24T17:44:37Z","lastAt":"2009-01-24T17:44:37Z","messageCount":1,"participants":["Allan Caffee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101755","messageId":"20090124174437.GA10125@linux.vnet","threadId":"17341","inReplyTo":null,"subject":"[PATCH] git-svn: Don't fail `--help' if git directory not found.","fromName":"Allan Caffee","fromEmail":"allan.caffee@gmail.com","sentAt":"2009-01-24T17:44:37Z","receivedAt":"2009-01-24T17:44:37Z","isPatch":true,"sender":{"key":"allan.caffee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/114759?v=4"},"body":"When called with the `--help' or `--version' from outside of a working tree\ngit-svn would fail with\n\n\tfatal: Not a git repository\n\trev-parse --show-cdup: command returned error: 128\n\nThis happens because git-svn would check that it was running from the top of a\nworking directory before parsing options.  Fix this by parsing options first.\n\nSigned-off-by: Allan Caffee <allan.caffee@gmail.com>\n---\n git-svn.perl |   38 +++++++++++++++++++-------------------\n 1 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex d4cb538..875a05b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -216,6 +216,25 @@ for (my $i = 0; $i < @ARGV; $i++) {\n \t}\n };\n \n+my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);\n+\n+read_repo_config(\\%opts);\n+if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {\n+\tGetopt::Long::Configure('pass_through');\n+}\n+my $rv = GetOptions(%opts, 'help|H|h' => \\$_help, 'version|V' => \\$_version,\n+                    'minimize-connections' => \\$Git::SVN::Migration::_minimize,\n+                    'id|i=s' => \\$Git::SVN::default_ref_id,\n+                    'svn-remote|remote|R=s' => sub {\n+                       $Git::SVN::no_reuse_existing = 1;\n+                       $Git::SVN::default_repo_id = $_[1] });\n+exit 1 if (!$rv && $cmd && $cmd ne 'log');\n+\n+usage(0) if $_help;\n+version() if $_version;\n+usage(1) unless defined $cmd;\n+load_authors() if $_authors;\n+\n # make sure we're always running at the top-level working directory\n unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {\n \tunless (-d $ENV{GIT_DIR}) {\n@@ -241,25 +260,6 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {\n \t$_repository = Git->repository(Repository => $ENV{GIT_DIR});\n }\n \n-my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);\n-\n-read_repo_config(\\%opts);\n-if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {\n-\tGetopt::Long::Configure('pass_through');\n-}\n-my $rv = GetOptions(%opts, 'help|H|h' => \\$_help, 'version|V' => \\$_version,\n-                    'minimize-connections' => \\$Git::SVN::Migration::_minimize,\n-                    'id|i=s' => \\$Git::SVN::default_ref_id,\n-                    'svn-remote|remote|R=s' => sub {\n-                       $Git::SVN::no_reuse_existing = 1;\n-                       $Git::SVN::default_repo_id = $_[1] });\n-exit 1 if (!$rv && $cmd && $cmd ne 'log');\n-\n-usage(0) if $_help;\n-version() if $_version;\n-usage(1) unless defined $cmd;\n-load_authors() if $_authors;\n-\n unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {\n \tGit::SVN::Migration::migration_check();\n }\n-- \n1.5.4.3\n"}]}