From: "David D. Kilzer" <ddkilzer@kilzer.net>
To: "Eric Wong" <normalperson@yhbt.net>
Cc: git@vger.kernel.org, "David D. Kilzer" <ddkilzer@kilzer.net>
Subject: [PATCH 3/3 v3] git-svn: info --url [path]
Date: Wed, 21 Nov 2007 11:57:19 -0800 [thread overview]
Message-ID: <1195675039-26746-4-git-send-email-ddkilzer@kilzer.net> (raw)
In-Reply-To: <1195675039-26746-3-git-send-email-ddkilzer@kilzer.net>
Return the svn URL for the given path, or return the svn
repository URL if no path is given.
Added 18 tests to t/t9119-git-svn-info.sh.
Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
---
Documentation/git-svn.txt | 3 +-
git-svn.perl | 9 +++-
t/t9119-git-svn-info.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index c3fc878..918a992 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -196,7 +196,8 @@ Any other arguments are passed directly to `git log'
'info'::
Shows information about a file or directory similar to what
`svn info' provides. Does not currently support a -r/--revision
- argument.
+ argument. Use the --url option to output only the value of the
+ 'URL:' field.
--
diff --git a/git-svn.perl b/git-svn.perl
index be9290c..62801c8 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -65,7 +65,7 @@ my ($_stdin, $_help, $_edit,
$_template, $_shared,
$_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local,
- $_prefix, $_no_checkout, $_verbose);
+ $_prefix, $_no_checkout, $_url, $_verbose);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -181,7 +181,7 @@ my %cmd = (
'info' => [ \&cmd_info,
"Show info about the latest SVN revision
on the current branch",
- { } ],
+ { 'url' => \$_url, } ],
);
my $cmd;
@@ -773,6 +773,11 @@ sub cmd_info {
}
my $full_url = $url . ($path eq "." ? "" : "/$path");
+ if ($_url) {
+ print $full_url, "\n";
+ return;
+ }
+
my $result = "Path: $path\n";
$result .= "Name: " . basename($path) . "\n" if $file_type ne "dir";
$result .= "URL: " . $full_url . "\n";
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index edd64d6..e81457f 100644
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -44,30 +44,51 @@ test_expect_success 'info' "
git-diff expected.info actual.info
"
+test_expect_success 'info --url' '
+ test $(cd gitwc; git-svn info --url) = $svnrepo
+ '
+
test_expect_success 'info .' "
(cd svnwc; svn info .) > expected.info-dot &&
(cd gitwc; git-svn info .) > actual.info-dot &&
git-diff expected.info-dot actual.info-dot
"
+test_expect_success 'info --url .' '
+ test $(cd gitwc; git-svn info --url .) = $svnrepo
+ '
+
test_expect_success 'info file' "
(cd svnwc; svn info file) > expected.info-file &&
(cd gitwc; git-svn info file) > actual.info-file &&
git-diff expected.info-file actual.info-file
"
+test_expect_success 'info --url file' '
+ test $(cd gitwc; git-svn info --url file) = "$svnrepo/file"
+ '
+
test_expect_success 'info directory' "
(cd svnwc; svn info directory) > expected.info-directory &&
(cd gitwc; git-svn info directory) > actual.info-directory &&
git-diff expected.info-directory actual.info-directory
"
+test_expect_success 'info --url directory' '
+ test $(cd gitwc; git-svn info --url directory) = "$svnrepo/directory"
+ '
+
test_expect_success 'info symlink-file' "
(cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
(cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
git-diff expected.info-symlink-file actual.info-symlink-file
"
+test_expect_success 'info --url symlink-file' '
+ test $(cd gitwc; git-svn info --url symlink-file) \
+ = "$svnrepo/symlink-file"
+ '
+
test_expect_success 'info symlink-directory' "
(cd svnwc; svn info symlink-directory) \
> expected.info-symlink-directory &&
@@ -76,6 +97,11 @@ test_expect_success 'info symlink-directory' "
git-diff expected.info-symlink-directory actual.info-symlink-directory
"
+test_expect_success 'info --url symlink-directory' '
+ test $(cd gitwc; git-svn info --url symlink-directory) \
+ = "$svnrepo/symlink-directory"
+ '
+
test_expect_success 'info added-file' "
echo two > gitwc/added-file &&
cd gitwc &&
@@ -91,6 +117,11 @@ test_expect_success 'info added-file' "
git-diff expected.info-added-file actual.info-added-file
"
+test_expect_success 'info --url added-file' '
+ test $(cd gitwc; git-svn info --url added-file) \
+ = "$svnrepo/added-file"
+ '
+
test_expect_success 'info added-directory' "
mkdir gitwc/added-directory svnwc/added-directory &&
ptouch gitwc/added-directory svnwc/added-directory &&
@@ -108,6 +139,11 @@ test_expect_success 'info added-directory' "
git-diff expected.info-added-directory actual.info-added-directory
"
+test_expect_success 'info --url added-directory' '
+ test $(cd gitwc; git-svn info --url added-directory) \
+ = "$svnrepo/added-directory"
+ '
+
test_expect_success 'info added-symlink-file' "
cd gitwc &&
ln -s added-file added-symlink-file &&
@@ -126,6 +162,11 @@ test_expect_success 'info added-symlink-file' "
actual.info-added-symlink-file
"
+test_expect_success 'info --url added-symlink-file' '
+ test $(cd gitwc; git-svn info --url added-symlink-file) \
+ = "$svnrepo/added-symlink-file"
+ '
+
test_expect_success 'info added-symlink-directory' "
cd gitwc &&
ln -s added-directory added-symlink-directory &&
@@ -144,6 +185,11 @@ test_expect_success 'info added-symlink-directory' "
actual.info-added-symlink-directory
"
+test_expect_success 'info --url added-symlink-directory' '
+ test $(cd gitwc; git-svn info --url added-symlink-directory) \
+ = "$svnrepo/added-symlink-directory"
+ '
+
# The next few tests replace the "Text Last Updated" value with a
# placeholder since git doesn't have a way to know the date that a
# now-deleted file was last checked out locally. Internally it
@@ -165,6 +211,11 @@ test_expect_success 'info deleted-file' "
git-diff expected.info-deleted-file actual.info-deleted-file
"
+test_expect_success 'info --url file (deleted)' '
+ test $(cd gitwc; git-svn info --url file) \
+ = "$svnrepo/file"
+ '
+
test_expect_success 'info deleted-directory' "
cd gitwc &&
git rm -r -f directory > /dev/null &&
@@ -181,6 +232,11 @@ test_expect_success 'info deleted-directory' "
git-diff expected.info-deleted-directory actual.info-deleted-directory
"
+test_expect_success 'info --url directory (deleted)' '
+ test $(cd gitwc; git-svn info --url directory) \
+ = "$svnrepo/directory"
+ '
+
test_expect_success 'info deleted-symlink-file' "
cd gitwc &&
git rm -f symlink-file > /dev/null &&
@@ -198,6 +254,11 @@ test_expect_success 'info deleted-symlink-file' "
actual.info-deleted-symlink-file
"
+test_expect_success 'info --url symlink-file (deleted)' '
+ test $(cd gitwc; git-svn info --url symlink-file) \
+ = "$svnrepo/symlink-file"
+ '
+
test_expect_success 'info deleted-symlink-directory' "
cd gitwc &&
git rm -f symlink-directory > /dev/null &&
@@ -215,6 +276,11 @@ test_expect_success 'info deleted-symlink-directory' "
actual.info-deleted-symlink-directory
"
+test_expect_success 'info --url symlink-directory (deleted)' '
+ test $(cd gitwc; git-svn info --url symlink-directory) \
+ = "$svnrepo/symlink-directory"
+ '
+
# NOTE: git does not have the concept of replaced objects,
# so we can't test for files in that state.
@@ -227,6 +293,12 @@ test_expect_success 'info unknown-file' "
git-diff expected.info-unknown-file actual.info-unknown-file
"
+test_expect_success 'info --url unknown-file' '
+ test -z $(cd gitwc; git-svn info --url unknown-file \
+ 2> ../actual.info--url-unknown-file) &&
+ git-diff expected.info-unknown-file actual.info--url-unknown-file
+ '
+
test_expect_success 'info unknown-directory' "
mkdir gitwc/unknown-directory svnwc/unknown-directory &&
ptouch gitwc/unknown-directory svnwc/unknown-directory &&
@@ -238,6 +310,13 @@ test_expect_success 'info unknown-directory' "
git-diff expected.info-unknown-directory actual.info-unknown-directory
"
+test_expect_success 'info --url unknown-directory' '
+ test -z $(cd gitwc; git-svn info --url unknown-directory \
+ 2> ../actual.info--url-unknown-directory) &&
+ git-diff expected.info-unknown-directory \
+ actual.info--url-unknown-directory
+ '
+
test_expect_success 'info unknown-symlink-file' "
cd gitwc &&
ln -s unknown-file unknown-symlink-file &&
@@ -254,6 +333,13 @@ test_expect_success 'info unknown-symlink-file' "
actual.info-unknown-symlink-file
"
+test_expect_success 'info --url unknown-symlink-file' '
+ test -z $(cd gitwc; git-svn info --url unknown-symlink-file \
+ 2> ../actual.info--url-unknown-symlink-file) &&
+ git-diff expected.info-unknown-symlink-file \
+ actual.info--url-unknown-symlink-file
+ '
+
test_expect_success 'info unknown-symlink-directory' "
cd gitwc &&
ln -s unknown-directory unknown-symlink-directory &&
@@ -271,4 +357,11 @@ test_expect_success 'info unknown-symlink-directory' "
actual.info-unknown-symlink-directory
"
+test_expect_success 'info --url unknown-symlink-directory' '
+ test -z $(cd gitwc; git-svn info --url unknown-symlink-directory \
+ 2> ../actual.info--url-unknown-symlink-directory) &&
+ git-diff expected.info-unknown-symlink-directory \
+ actual.info--url-unknown-symlink-directory
+ '
+
test_done
--
1.5.3.4
next prev parent reply other threads:[~2007-11-21 19:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-21 19:57 [PATCH 0/3 v3] Implement git-svn info David D. Kilzer
2007-11-21 19:57 ` [PATCH 1/3 v3] git-svn: extract reusable code into utility functions David D. Kilzer
2007-11-21 19:57 ` [PATCH 2/3 v3] git-svn info: implement info command David D. Kilzer
2007-11-21 19:57 ` David D. Kilzer [this message]
2007-11-22 1:40 ` Eric Wong
2007-11-22 3:16 ` David D. Kilzer
2007-11-22 4:17 ` Eric Wong
2007-11-22 1:19 ` [PATCH 1/3 v3] git-svn: extract reusable code into utility functions Eric Wong
2007-11-22 2:23 ` [PATCH 4/3] git-svn: allow `info' command to work offline Eric Wong
2007-11-22 3:24 ` Adam Roben
2007-11-22 3:56 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1195675039-26746-4-git-send-email-ddkilzer@kilzer.net \
--to=ddkilzer@kilzer.net \
--cc=git@vger.kernel.org \
--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.
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 NNTP newsgroup(s).