Skip to content

Commit

Permalink
git-svn: allow --version to work anywhere
Browse files Browse the repository at this point in the history
Checking the version of the installed SVN libraries should not
require a git repository at all.  This matches the behavior of
"git --version".

Add a test for "git svn help" for the same behavior while we're
at it, too.

Signed-off-by: Eric Wong <e@80x24.org>
  • Loading branch information
Eric Wong committed Jul 22, 2016
1 parent cec9264 commit c0071ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ sub term_init {
die "failed to open $ENV{GIT_DIR}: $!\n";
$ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
}
} else {
} elsif ($cmd) {
my ($git_dir, $cdup);
git_cmd_try {
$git_dir = command_oneline([qw/rev-parse --git-dir/]);
Expand All @@ -356,7 +356,7 @@ sub term_init {

my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);

read_git_config(\%opts);
read_git_config(\%opts) if $ENV{GIT_DIR};
if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
Getopt::Long::Configure('pass_through');
}
Expand Down
19 changes: 19 additions & 0 deletions t/t9100-git-svn-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ case "$GIT_SVN_LC_ALL" in
;;
esac

deepdir=nothing-above
ceiling=$PWD

test_expect_success 'git svn --version works anywhere' '
mkdir -p "$deepdir" && (
export GIT_CEILING_DIRECTORIES="$ceiling" &&
cd "$deepdir" &&
git svn --version
)
'

test_expect_success 'git svn help works anywhere' '
mkdir -p "$deepdir" && (
export GIT_CEILING_DIRECTORIES="$ceiling" &&
cd "$deepdir" &&
git svn help
)
'

test_expect_success \
'initialize git svn' '
mkdir import &&
Expand Down

0 comments on commit c0071ae

Please sign in to comment.