git-svn: info --url [path]
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> Acked-by: Eric Wong <normalperson@yhbt.net>
David D. Kilzer committed
Nov 21, 2007 at 11:57 UTC
8b014d7157d29ce76b0f631e19c6e2ce9aeb2366
3 files changed
+102
-3
Documentation/git-svn.txt
+2
-1
@@ -196,7 +196,8 @@ Any other arguments are passed directly to `git log'
196
'info'::
197
Shows information about a file or directory similar to what
198
`svn info' provides. Does not currently support a -r/--revision
199
- argument.
199
+ argument. Use the --url option to output only the value of the
200
+ 'URL:' field.
201
202
--
203
git-svn.perl
+7
-2
@@ -65,7 +65,7 @@ my ($_stdin, $_help, $_edit,
65
$_template, $_shared,
66
$_version, $_fetch_all, $_no_rebase,
67
$_merge, $_strategy, $_dry_run, $_local,
68
- $_prefix, $_no_checkout, $_verbose);
68
+ $_prefix, $_no_checkout, $_url, $_verbose);
69
$Git::SVN::_follow_parent = 1;
70
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
71
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -181,7 +181,7 @@ my %cmd = (
181
'info' => [ \&cmd_info,
182
"Show info about the latest SVN revision
183
on the current branch",
184
- { } ],
184
+ { 'url' => \$_url, } ],
185
);
186
187
my $cmd;
@@ -773,6 +773,11 @@ sub cmd_info {
773
}
774
my $full_url = $url . ($path eq "." ? "" : "/$path");
775
776
+ if ($_url) {
777
+ print $full_url, "\n";
778
+ return;
779
+ }
780
+
781
my $result = "Path: $path\n";
782
$result .= "Name: " . basename($path) . "\n" if $file_type ne "dir";
783
$result .= "URL: " . $full_url . "\n";
t/t9119-git-svn-info.sh
+93
@@ -45,30 +45,51 @@ test_expect_success 'info' "
45
git-diff expected.info actual.info
46
"
47
48
+test_expect_success 'info --url' '
49
+ test $(cd gitwc; git-svn info --url) = $svnrepo
50
+ '
51
+
52
test_expect_success 'info .' "
53
(cd svnwc; svn info .) > expected.info-dot &&
54
(cd gitwc; git-svn info .) > actual.info-dot &&
55
git-diff expected.info-dot actual.info-dot
56
"
57
58
+test_expect_success 'info --url .' '
59
+ test $(cd gitwc; git-svn info --url .) = $svnrepo
60
+ '
61
+
62
test_expect_success 'info file' "
63
(cd svnwc; svn info file) > expected.info-file &&
64
(cd gitwc; git-svn info file) > actual.info-file &&
65
git-diff expected.info-file actual.info-file
66
"
67
68
+test_expect_success 'info --url file' '
69
+ test $(cd gitwc; git-svn info --url file) = "$svnrepo/file"
70
+ '
71
+
72
test_expect_success 'info directory' "
73
(cd svnwc; svn info directory) > expected.info-directory &&
74
(cd gitwc; git-svn info directory) > actual.info-directory &&
75
git-diff expected.info-directory actual.info-directory
76
"
77
78
+test_expect_success 'info --url directory' '
79
+ test $(cd gitwc; git-svn info --url directory) = "$svnrepo/directory"
80
+ '
81
+
82
test_expect_success 'info symlink-file' "
83
(cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
84
(cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
85
git-diff expected.info-symlink-file actual.info-symlink-file
86
"
87
88
+test_expect_success 'info --url symlink-file' '
89
+ test $(cd gitwc; git-svn info --url symlink-file) \
90
+ = "$svnrepo/symlink-file"
91
+ '
92
+
93
test_expect_success 'info symlink-directory' "
94
(cd svnwc; svn info symlink-directory) \
95
> expected.info-symlink-directory &&
@@ -77,6 +98,11 @@ test_expect_success 'info symlink-directory' "
98
git-diff expected.info-symlink-directory actual.info-symlink-directory
99
"
100
101
+test_expect_success 'info --url symlink-directory' '
102
+ test $(cd gitwc; git-svn info --url symlink-directory) \
103
+ = "$svnrepo/symlink-directory"
104
+ '
105
+
106
test_expect_success 'info added-file' "
107
echo two > gitwc/added-file &&
108
cd gitwc &&
@@ -92,6 +118,11 @@ test_expect_success 'info added-file' "
118
git-diff expected.info-added-file actual.info-added-file
119
"
120
121
+test_expect_success 'info --url added-file' '
122
+ test $(cd gitwc; git-svn info --url added-file) \
123
+ = "$svnrepo/added-file"
124
+ '
125
+
126
test_expect_success 'info added-directory' "
127
mkdir gitwc/added-directory svnwc/added-directory &&
128
ptouch gitwc/added-directory svnwc/added-directory &&
@@ -109,6 +140,11 @@ test_expect_success 'info added-directory' "
140
git-diff expected.info-added-directory actual.info-added-directory
141
"
142
143
+test_expect_success 'info --url added-directory' '
144
+ test $(cd gitwc; git-svn info --url added-directory) \
145
+ = "$svnrepo/added-directory"
146
+ '
147
+
148
test_expect_success 'info added-symlink-file' "
149
cd gitwc &&
150
ln -s added-file added-symlink-file &&
@@ -127,6 +163,11 @@ test_expect_success 'info added-symlink-file' "
163
actual.info-added-symlink-file
164
"
165
166
+test_expect_success 'info --url added-symlink-file' '
167
+ test $(cd gitwc; git-svn info --url added-symlink-file) \
168
+ = "$svnrepo/added-symlink-file"
169
+ '
170
+
171
test_expect_success 'info added-symlink-directory' "
172
cd gitwc &&
173
ln -s added-directory added-symlink-directory &&
@@ -145,6 +186,11 @@ test_expect_success 'info added-symlink-directory' "
186
actual.info-added-symlink-directory
187
"
188
189
+test_expect_success 'info --url added-symlink-directory' '
190
+ test $(cd gitwc; git-svn info --url added-symlink-directory) \
191
+ = "$svnrepo/added-symlink-directory"
192
+ '
193
+
194
# The next few tests replace the "Text Last Updated" value with a
195
# placeholder since git doesn't have a way to know the date that a
196
# now-deleted file was last checked out locally. Internally it
@@ -166,6 +212,11 @@ test_expect_success 'info deleted-file' "
212
git-diff expected.info-deleted-file actual.info-deleted-file
213
"
214
215
+test_expect_success 'info --url file (deleted)' '
216
+ test $(cd gitwc; git-svn info --url file) \
217
+ = "$svnrepo/file"
218
+ '
219
+
220
test_expect_success 'info deleted-directory' "
221
cd gitwc &&
222
git rm -r -f directory > /dev/null &&
@@ -182,6 +233,11 @@ test_expect_success 'info deleted-directory' "
233
git-diff expected.info-deleted-directory actual.info-deleted-directory
234
"
235
236
+test_expect_success 'info --url directory (deleted)' '
237
+ test $(cd gitwc; git-svn info --url directory) \
238
+ = "$svnrepo/directory"
239
+ '
240
+
241
test_expect_success 'info deleted-symlink-file' "
242
cd gitwc &&
243
git rm -f symlink-file > /dev/null &&
@@ -199,6 +255,11 @@ test_expect_success 'info deleted-symlink-file' "
255
actual.info-deleted-symlink-file
256
"
257
258
+test_expect_success 'info --url symlink-file (deleted)' '
259
+ test $(cd gitwc; git-svn info --url symlink-file) \
260
+ = "$svnrepo/symlink-file"
261
+ '
262
+
263
test_expect_success 'info deleted-symlink-directory' "
264
cd gitwc &&
265
git rm -f symlink-directory > /dev/null &&
@@ -216,6 +277,11 @@ test_expect_success 'info deleted-symlink-directory' "
277
actual.info-deleted-symlink-directory
278
"
279
280
+test_expect_success 'info --url symlink-directory (deleted)' '
281
+ test $(cd gitwc; git-svn info --url symlink-directory) \
282
+ = "$svnrepo/symlink-directory"
283
+ '
284
+
285
# NOTE: git does not have the concept of replaced objects,
286
# so we can't test for files in that state.
287
@@ -228,6 +294,12 @@ test_expect_success 'info unknown-file' "
294
git-diff expected.info-unknown-file actual.info-unknown-file
295
"
296
297
+test_expect_success 'info --url unknown-file' '
298
+ test -z $(cd gitwc; git-svn info --url unknown-file \
299
+ 2> ../actual.info--url-unknown-file) &&
300
+ git-diff expected.info-unknown-file actual.info--url-unknown-file
301
+ '
302
+
303
test_expect_success 'info unknown-directory' "
304
mkdir gitwc/unknown-directory svnwc/unknown-directory &&
305
ptouch gitwc/unknown-directory svnwc/unknown-directory &&
@@ -239,6 +311,13 @@ test_expect_success 'info unknown-directory' "
311
git-diff expected.info-unknown-directory actual.info-unknown-directory
312
"
313
314
+test_expect_success 'info --url unknown-directory' '
315
+ test -z $(cd gitwc; git-svn info --url unknown-directory \
316
+ 2> ../actual.info--url-unknown-directory) &&
317
+ git-diff expected.info-unknown-directory \
318
+ actual.info--url-unknown-directory
319
+ '
320
+
321
test_expect_success 'info unknown-symlink-file' "
322
cd gitwc &&
323
ln -s unknown-file unknown-symlink-file &&
@@ -255,6 +334,13 @@ test_expect_success 'info unknown-symlink-file' "
334
actual.info-unknown-symlink-file
335
"
336
337
+test_expect_success 'info --url unknown-symlink-file' '
338
+ test -z $(cd gitwc; git-svn info --url unknown-symlink-file \
339
+ 2> ../actual.info--url-unknown-symlink-file) &&
340
+ git-diff expected.info-unknown-symlink-file \
341
+ actual.info--url-unknown-symlink-file
342
+ '
343
+
344
test_expect_success 'info unknown-symlink-directory' "
345
cd gitwc &&
346
ln -s unknown-directory unknown-symlink-directory &&
@@ -272,4 +358,11 @@ test_expect_success 'info unknown-symlink-directory' "
358
actual.info-unknown-symlink-directory
359
"
360
361
+test_expect_success 'info --url unknown-symlink-directory' '
362
+ test -z $(cd gitwc; git-svn info --url unknown-symlink-directory \
363
+ 2> ../actual.info--url-unknown-symlink-directory) &&
364
+ git-diff expected.info-unknown-symlink-directory \
365
+ actual.info--url-unknown-symlink-directory
366
+ '
367
+
368
test_done