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
This commit is contained in:
commit
50a6b54c03
37
git-svn.perl
37
git-svn.perl
@ -61,8 +61,6 @@ my $cmd_dir_prefix = eval {
|
|||||||
command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
|
command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
|
||||||
} || '';
|
} || '';
|
||||||
|
|
||||||
my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
|
|
||||||
$ENV{GIT_DIR} ||= '.git';
|
|
||||||
$Git::SVN::Ra::_log_window_size = 100;
|
$Git::SVN::Ra::_log_window_size = 100;
|
||||||
|
|
||||||
if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
|
if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
|
||||||
@ -327,27 +325,20 @@ for (my $i = 0; $i < @ARGV; $i++) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# make sure we're always running at the top-level working directory
|
# make sure we're always running at the top-level working directory
|
||||||
unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
|
if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
|
||||||
unless (-d $ENV{GIT_DIR}) {
|
$ENV{GIT_DIR} ||= ".git";
|
||||||
if ($git_dir_user_set) {
|
} else {
|
||||||
die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
|
my ($git_dir, $cdup);
|
||||||
"but it is not a directory\n";
|
git_cmd_try {
|
||||||
}
|
$git_dir = command_oneline([qw/rev-parse --git-dir/]);
|
||||||
my $git_dir = delete $ENV{GIT_DIR};
|
} "Unable to find .git directory\n";
|
||||||
my $cdup = undef;
|
git_cmd_try {
|
||||||
git_cmd_try {
|
$cdup = command_oneline(qw/rev-parse --show-cdup/);
|
||||||
$cdup = command_oneline(qw/rev-parse --show-cdup/);
|
chomp $cdup if ($cdup);
|
||||||
$git_dir = '.' unless ($cdup);
|
$cdup = "." unless ($cdup && length $cdup);
|
||||||
chomp $cdup if ($cdup);
|
} "Already at toplevel, but $git_dir not found\n";
|
||||||
$cdup = "." unless ($cdup && length $cdup);
|
$ENV{GIT_DIR} = $git_dir;
|
||||||
} "Already at toplevel, but $git_dir not found\n";
|
chdir $cdup or die "Unable to chdir up to '$cdup'\n";
|
||||||
chdir $cdup or die "Unable to chdir up to '$cdup'\n";
|
|
||||||
unless (-d $git_dir) {
|
|
||||||
die "$git_dir still not found after going to ",
|
|
||||||
"'$cdup'\n";
|
|
||||||
}
|
|
||||||
$ENV{GIT_DIR} = $git_dir;
|
|
||||||
}
|
|
||||||
$_repository = Git->repository(Repository => $ENV{GIT_DIR});
|
$_repository = Git->repository(Repository => $ENV{GIT_DIR});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ sub refname {
|
|||||||
#
|
#
|
||||||
# Additionally, % must be escaped because it is used for escaping
|
# Additionally, % must be escaped because it is used for escaping
|
||||||
# and we want our escaped refname to be reversible
|
# and we want our escaped refname to be reversible
|
||||||
$refname =~ s{([ \%~\^:\?\*\[\t])}{uc sprintf('%%%02x',ord($1))}eg;
|
$refname =~ s{([ \%~\^:\?\*\[\t])}{sprintf('%%%02X',ord($1))}eg;
|
||||||
|
|
||||||
# no slash-separated component can begin with a dot .
|
# no slash-separated component can begin with a dot .
|
||||||
# /.* becomes /%2E*
|
# /.* becomes /%2E*
|
||||||
@ -2377,7 +2377,7 @@ sub map_path {
|
|||||||
|
|
||||||
sub uri_encode {
|
sub uri_encode {
|
||||||
my ($f) = @_;
|
my ($f) = @_;
|
||||||
$f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#uc sprintf("%%%02x",ord($1))#eg;
|
$f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#sprintf("%%%02X",ord($1))#eg;
|
||||||
$f
|
$f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ sub url_path {
|
|||||||
my ($self, $path) = @_;
|
my ($self, $path) = @_;
|
||||||
if ($self->{url} =~ m#^https?://#) {
|
if ($self->{url} =~ m#^https?://#) {
|
||||||
# characters are taken from subversion/libsvn_subr/path.c
|
# characters are taken from subversion/libsvn_subr/path.c
|
||||||
$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#uc sprintf("%%%02x",ord($1))#eg;
|
$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg;
|
||||||
}
|
}
|
||||||
$self->{url} . '/' . $self->repo_path($path);
|
$self->{url} . '/' . $self->repo_path($path);
|
||||||
}
|
}
|
||||||
|
@ -306,5 +306,13 @@ test_expect_success 'git-svn works in a bare repository' '
|
|||||||
git svn fetch ) &&
|
git svn fetch ) &&
|
||||||
rm -rf bare-repo
|
rm -rf bare-repo
|
||||||
'
|
'
|
||||||
|
test_expect_success 'git-svn works in in a repository with a gitdir: link' '
|
||||||
|
mkdir worktree gitdir &&
|
||||||
|
( cd worktree &&
|
||||||
|
git svn init "$svnrepo" &&
|
||||||
|
git init --separate-git-dir ../gitdir &&
|
||||||
|
git svn fetch ) &&
|
||||||
|
rm -rf worktree gitdir
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user