Skip to content

Commit 50a6b54

Browse files
committed
Merge branch 'for-junio' of git://bogomips.org/git-svn
* 'for-junio' of git://bogomips.org/git-svn: git-svn: Simplify calculation of GIT_DIR git-svn: cleanup sprintf usage for uppercasing hex
2 parents 3587b51 + bc93ceb commit 50a6b54

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

git-svn.perl

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ BEGIN
6161
command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
6262
} || '';
6363

64-
my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
65-
$ENV{GIT_DIR} ||= '.git';
6664
$Git::SVN::Ra::_log_window_size = 100;
6765

6866
if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
@@ -327,27 +325,20 @@ package main;
327325
};
328326

329327
# make sure we're always running at the top-level working directory
330-
unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
331-
unless (-d $ENV{GIT_DIR}) {
332-
if ($git_dir_user_set) {
333-
die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
334-
"but it is not a directory\n";
335-
}
336-
my $git_dir = delete $ENV{GIT_DIR};
337-
my $cdup = undef;
338-
git_cmd_try {
339-
$cdup = command_oneline(qw/rev-parse --show-cdup/);
340-
$git_dir = '.' unless ($cdup);
341-
chomp $cdup if ($cdup);
342-
$cdup = "." unless ($cdup && length $cdup);
343-
} "Already at toplevel, but $git_dir not found\n";
344-
chdir $cdup or die "Unable to chdir up to '$cdup'\n";
345-
unless (-d $git_dir) {
346-
die "$git_dir still not found after going to ",
347-
"'$cdup'\n";
348-
}
349-
$ENV{GIT_DIR} = $git_dir;
350-
}
328+
if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
329+
$ENV{GIT_DIR} ||= ".git";
330+
} else {
331+
my ($git_dir, $cdup);
332+
git_cmd_try {
333+
$git_dir = command_oneline([qw/rev-parse --git-dir/]);
334+
} "Unable to find .git directory\n";
335+
git_cmd_try {
336+
$cdup = command_oneline(qw/rev-parse --show-cdup/);
337+
chomp $cdup if ($cdup);
338+
$cdup = "." unless ($cdup && length $cdup);
339+
} "Already at toplevel, but $git_dir not found\n";
340+
$ENV{GIT_DIR} = $git_dir;
341+
chdir $cdup or die "Unable to chdir up to '$cdup'\n";
351342
$_repository = Git->repository(Repository => $ENV{GIT_DIR});
352343
}
353344

perl/Git/SVN.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ sub refname {
490490
#
491491
# Additionally, % must be escaped because it is used for escaping
492492
# and we want our escaped refname to be reversible
493-
$refname =~ s{([ \%~\^:\?\*\[\t])}{uc sprintf('%%%02x',ord($1))}eg;
493+
$refname =~ s{([ \%~\^:\?\*\[\t])}{sprintf('%%%02X',ord($1))}eg;
494494

495495
# no slash-separated component can begin with a dot .
496496
# /.* becomes /%2E*
@@ -2377,7 +2377,7 @@ sub map_path {
23772377

23782378
sub uri_encode {
23792379
my ($f) = @_;
2380-
$f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#uc sprintf("%%%02x",ord($1))#eg;
2380+
$f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#sprintf("%%%02X",ord($1))#eg;
23812381
$f
23822382
}
23832383

perl/Git/SVN/Editor.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ sub url_path {
146146
my ($self, $path) = @_;
147147
if ($self->{url} =~ m#^https?://#) {
148148
# characters are taken from subversion/libsvn_subr/path.c
149-
$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#uc sprintf("%%%02x",ord($1))#eg;
149+
$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg;
150150
}
151151
$self->{url} . '/' . $self->repo_path($path);
152152
}

t/t9100-git-svn-basic.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,13 @@ test_expect_success 'git-svn works in a bare repository' '
306306
git svn fetch ) &&
307307
rm -rf bare-repo
308308
'
309+
test_expect_success 'git-svn works in in a repository with a gitdir: link' '
310+
mkdir worktree gitdir &&
311+
( cd worktree &&
312+
git svn init "$svnrepo" &&
313+
git init --separate-git-dir ../gitdir &&
314+
git svn fetch ) &&
315+
rm -rf worktree gitdir
316+
'
309317

310318
test_done

0 commit comments

Comments
 (0)