git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: git@vger.kernel.org
Cc: Eric Wong <normalperson@yhbt.net>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 5/6] git svn info: make info relative to the current directory
Date: Tue, 26 Aug 2008 21:32:36 +0200	[thread overview]
Message-ID: <1219779157-31602-6-git-send-email-trast@student.ethz.ch> (raw)
In-Reply-To: <1219779157-31602-5-git-send-email-trast@student.ethz.ch>

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>
---

I realise that this might break things for people who rely on the
current behaviour, but looking at the tests, the goal is to imitate
'svn info' as closely as possible.  This also matches my use case of
'svn info || git svn info', which is why I stumbled over the problem
in the first place.


 git-svn.perl            |    5 +++--
 t/t9119-git-svn-info.sh |   14 +++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 7a1d26d..46bc0b0 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -805,6 +805,7 @@ sub cmd_commit_diff {
 
 sub cmd_info {
 	my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
+	my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
 	if (exists $_[1]) {
 		die "Too many arguments specified\n";
 	}
@@ -825,7 +826,7 @@ sub cmd_info {
 	# canonicalize_path() will return "" to make libsvn 1.5.x happy,
 	$path = "." if $path eq "";
 
-	my $full_url = $url . ($path eq "." ? "" : "/$path");
+	my $full_url = $url . ($fullpath eq "" ? "" : "/$fullpath");
 
 	if ($_url) {
 		print $full_url, "\n";
@@ -861,7 +862,7 @@ sub cmd_info {
 	}
 
 	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 $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
 	while (<$log>) {
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index 821507d..8709bcc 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -45,12 +45,18 @@ test_expect_success 'setup repository and import' '
 		ln -s directory symlink-directory &&
 		svn import -m "initial" . "$svnrepo" &&
 	cd .. &&
+	svn co "$svnrepo" svnwc &&
+	cd svnwc &&
+		echo foo > foo &&
+		svn add foo &&
+		svn commit -m "change outside directory" &&
+		svn update &&
+	cd .. &&
 	mkdir gitwc &&
 	cd gitwc &&
 		git-svn init "$svnrepo" &&
 		git-svn fetch &&
 	cd .. &&
-	svn co "$svnrepo" svnwc &&
 	ptouch gitwc/file svnwc/file &&
 	ptouch gitwc/directory svnwc/directory &&
 	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_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 "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
 	'
-- 
1.6.0.1.96.g9307e.dirty

  reply	other threads:[~2008-08-26 19:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26 19:32 [PATCH 0/6] 'git svn info' fixes Thomas Rast
2008-08-26 19:32 ` [PATCH 1/6] git svn info: tests: let 'init' test run with SVN 1.5 Thomas Rast
2008-08-26 19:32   ` [PATCH 2/6] git svn info: tests: do not use set -e Thomas Rast
2008-08-26 19:32     ` [PATCH 3/6] git svn info: tests: use test_cmp instead of git-diff Thomas Rast
2008-08-26 19:32       ` [PATCH 4/6] git svn info: tests: fix ptouch argument order in setup Thomas Rast
2008-08-26 19:32         ` Thomas Rast [this message]
2008-08-26 19:32           ` [PATCH 6/6] git svn info: always quote URLs in 'info' output Thomas Rast
2008-08-27  9:43             ` Eric Wong
2008-08-27  9:53 ` [PATCH 0/6] 'git svn info' fixes Eric Wong
2008-08-28  8:30   ` Thomas Rast
2008-08-29  8:16     ` Eric Wong
2008-08-29 13:42       ` [PATCH 0/2] *** SUBJECT HERE *** Thomas Rast
2008-08-29 13:42         ` [PATCH 1/2] git-svn: match SVN 1.5 behaviour of info' on unknown item Thomas Rast
2008-08-29 13:42           ` [PATCH 2/2] git-svn: fix 'info' tests for unknown items Thomas Rast
2008-08-30  1:03         ` [PATCH 0/2] 'git svn info' fixes Eric Wong
2008-09-01  9:46           ` Thomas Rast
2008-09-01 22:58             ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1219779157-31602-6-git-send-email-trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).