threads / patch / 17341

patchgit-svn: Don't fail `--help' if git directory not found.

Subject: [PATCH] git-svn: Don't fail `--help' if git directory not found.

## tl;dr

One message between Jan 24, 2009 and Jan 24, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Allan Caffee· Jan 24, 2009, 17:44 UTC · lore

When called with the `--help' or `--version' from outside of a working tree git-svn would fail with

	fatal: Not a git repository
	rev-parse --show-cdup: command returned error: 128

This happens because git-svn would check that it was running from the top of a working directory before parsing options. Fix this by parsing options first.

Signed-off-by: Allan Caffee <allan.caffee@gmail.com>
---
 git-svn.perl |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
Show changes to git-svn.perl +19 −19
diff --git a/git-svn.perl b/git-svn.perl
index d4cb538..875a05b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -216,6 +216,25 @@ for (my $i = 0; $i < @ARGV; $i++) {
 	}
 };
 
+my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
+
+read_repo_config(\%opts);
+if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
+	Getopt::Long::Configure('pass_through');
+}
+my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
+                    'minimize-connections' => \$Git::SVN::Migration::_minimize,
+                    'id|i=s' => \$Git::SVN::default_ref_id,
+                    'svn-remote|remote|R=s' => sub {
+                       $Git::SVN::no_reuse_existing = 1;
+                       $Git::SVN::default_repo_id = $_[1] });
+exit 1 if (!$rv && $cmd && $cmd ne 'log');
+
+usage(0) if $_help;
+version() if $_version;
+usage(1) unless defined $cmd;
+load_authors() if $_authors;
+
 # make sure we're always running at the top-level working directory
 unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 	unless (-d $ENV{GIT_DIR}) {
@@ -241,25 +260,6 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 	$_repository = Git->repository(Repository => $ENV{GIT_DIR});
 }
 
-my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
-
-read_repo_config(\%opts);
-if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
-	Getopt::Long::Configure('pass_through');
-}
-my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
-                    'minimize-connections' => \$Git::SVN::Migration::_minimize,
-                    'id|i=s' => \$Git::SVN::default_ref_id,
-                    'svn-remote|remote|R=s' => sub {
-                       $Git::SVN::no_reuse_existing = 1;
-                       $Git::SVN::default_repo_id = $_[1] });
-exit 1 if (!$rv && $cmd && $cmd ne 'log');
-
-usage(0) if $_help;
-version() if $_version;
-usage(1) unless defined $cmd;
-load_authors() if $_authors;
-
 unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
 	Git::SVN::Migration::migration_check();
 }
-- 
1.5.4.3

← back to recent threads