git svn info: make info relative to the current directory
Previously 'git svn info <path>' would always treat the <path> as relative to the working directory root, with a default of ".". This does not match the behaviour of 'svn info'. Prepend $(git rev-parse --show-prefix) to the path used inside cmd_info to make it relative to the current working directory. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
@ -805,6 +805,7 @@ sub cmd_commit_diff {
|
|||||||
|
|
||||||
sub cmd_info {
|
sub cmd_info {
|
||||||
my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
|
my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
|
||||||
|
my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
|
||||||
if (exists $_[1]) {
|
if (exists $_[1]) {
|
||||||
die "Too many arguments specified\n";
|
die "Too many arguments specified\n";
|
||||||
}
|
}
|
||||||
@ -825,7 +826,7 @@ sub cmd_info {
|
|||||||
# canonicalize_path() will return "" to make libsvn 1.5.x happy,
|
# canonicalize_path() will return "" to make libsvn 1.5.x happy,
|
||||||
$path = "." if $path eq "";
|
$path = "." if $path eq "";
|
||||||
|
|
||||||
my $full_url = $url . ($path eq "." ? "" : "/$path");
|
my $full_url = $url . ($fullpath eq "" ? "" : "/$fullpath");
|
||||||
|
|
||||||
if ($_url) {
|
if ($_url) {
|
||||||
print $full_url, "\n";
|
print $full_url, "\n";
|
||||||
@ -861,7 +862,7 @@ sub cmd_info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my ($lc_author, $lc_rev, $lc_date_utc);
|
my ($lc_author, $lc_rev, $lc_date_utc);
|
||||||
my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $path);
|
my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $fullpath);
|
||||||
my $log = command_output_pipe(@args);
|
my $log = command_output_pipe(@args);
|
||||||
my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
|
my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
|
||||||
while (<$log>) {
|
while (<$log>) {
|
||||||
|
@ -45,12 +45,18 @@ test_expect_success 'setup repository and import' '
|
|||||||
ln -s directory symlink-directory &&
|
ln -s directory symlink-directory &&
|
||||||
svn import -m "initial" . "$svnrepo" &&
|
svn import -m "initial" . "$svnrepo" &&
|
||||||
cd .. &&
|
cd .. &&
|
||||||
|
svn co "$svnrepo" svnwc &&
|
||||||
|
cd svnwc &&
|
||||||
|
echo foo > foo &&
|
||||||
|
svn add foo &&
|
||||||
|
svn commit -m "change outside directory" &&
|
||||||
|
svn update &&
|
||||||
|
cd .. &&
|
||||||
mkdir gitwc &&
|
mkdir gitwc &&
|
||||||
cd gitwc &&
|
cd gitwc &&
|
||||||
git-svn init "$svnrepo" &&
|
git-svn init "$svnrepo" &&
|
||||||
git-svn fetch &&
|
git-svn fetch &&
|
||||||
cd .. &&
|
cd .. &&
|
||||||
svn co "$svnrepo" svnwc &&
|
|
||||||
ptouch gitwc/file svnwc/file &&
|
ptouch gitwc/file svnwc/file &&
|
||||||
ptouch gitwc/directory svnwc/directory &&
|
ptouch gitwc/directory svnwc/directory &&
|
||||||
ptouch gitwc/symlink-file svnwc/symlink-file &&
|
ptouch gitwc/symlink-file svnwc/symlink-file &&
|
||||||
@ -93,6 +99,12 @@ test_expect_success 'info directory' "
|
|||||||
test_cmp expected.info-directory actual.info-directory
|
test_cmp expected.info-directory actual.info-directory
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'info inside directory' "
|
||||||
|
(cd svnwc/directory; svn info) > expected.info-inside-directory &&
|
||||||
|
(cd gitwc/directory; git-svn info) > actual.info-inside-directory &&
|
||||||
|
test_cmp expected.info-inside-directory actual.info-inside-directory
|
||||||
|
"
|
||||||
|
|
||||||
test_expect_success 'info --url directory' '
|
test_expect_success 'info --url directory' '
|
||||||
test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
|
test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
|
||||||
'
|
'
|
||||||
|
Reference in New Issue
Block a user