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>
Thomas Rast committed
Aug 26, 2008 at 21:32 UTC
edde9112abd1ef5f4565468e8a9a500e0c03f900
2 files changed
+16
-3
git-svn.perl
+3
-2
@@ -805,6 +805,7 @@ sub cmd_commit_diff {
805
806
sub cmd_info {
807
my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
808
+ my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
809
if (exists $_[1]) {
810
die "Too many arguments specified\n";
811
}
@@ -825,7 +826,7 @@ sub cmd_info {
826
# canonicalize_path() will return "" to make libsvn 1.5.x happy,
827
$path = "." if $path eq "";
828
828
- my $full_url = $url . ($path eq "." ? "" : "/$path");
829
+ my $full_url = $url . ($fullpath eq "" ? "" : "/$fullpath");
830
831
if ($_url) {
832
print $full_url, "\n";
@@ -861,7 +862,7 @@ sub cmd_info {
862
}
863
864
my ($lc_author, $lc_rev, $lc_date_utc);
864
- my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $path);
865
+ my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $fullpath);
866
my $log = command_output_pipe(@args);
867
my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
868
while (<$log>) {
t/t9119-git-svn-info.sh
+13
-1
@@ -45,12 +45,18 @@ test_expect_success 'setup repository and import' '
45
ln -s directory symlink-directory &&
46
svn import -m "initial" . "$svnrepo" &&
47
cd .. &&
48
+ svn co "$svnrepo" svnwc &&
49
+ cd svnwc &&
50
+ echo foo > foo &&
51
+ svn add foo &&
52
+ svn commit -m "change outside directory" &&
53
+ svn update &&
54
+ cd .. &&
55
mkdir gitwc &&
56
cd gitwc &&
57
git-svn init "$svnrepo" &&
58
git-svn fetch &&
59
cd .. &&
53
- svn co "$svnrepo" svnwc &&
60
ptouch gitwc/file svnwc/file &&
61
ptouch gitwc/directory svnwc/directory &&
62
ptouch gitwc/symlink-file svnwc/symlink-file &&
@@ -93,6 +99,12 @@ test_expect_success 'info directory' "
99
test_cmp expected.info-directory actual.info-directory
100
"
101
102
+test_expect_success 'info inside directory' "
103
+ (cd svnwc/directory; svn info) > expected.info-inside-directory &&
104
+ (cd gitwc/directory; git-svn info) > actual.info-inside-directory &&
105
+ test_cmp expected.info-inside-directory actual.info-inside-directory
106
+ "
107
+
108
test_expect_success 'info --url directory' '
109
test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
110
'