git-svn: add a show-externals command.
show-externals can be used by scripts to provide svn:externals-like functionality. For example, a script can list all of the externals and then use check out the listed URLs at the appropriate paths, similar to what the svn client does. Said script (or perhaps git-svn itself, in the future) could simply invoke svn export on the paths, or it could go one further, using git-svn clone and even git-submodule together to better integrate externals checkouts. The implementation is shamelessly copied from show-ignores. A more general command to list user-specified properties is probably a better idea. Signed-off-by: Vineet Kumar <vineet@doorstop.net> Acked-by: Eric Wong <normalperson@yhbt.net>
Vineet Kumar committed
Nov 19, 2007 at 14:56 UTC
2d8797921511b141a6d1b2f74f763f5e9197cc40
1 file changed
+18
git-svn.perl
+18
@@ -143,6 +143,9 @@ my %cmd = (
143
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
144
{ 'revision|r=i' => \$_revision
145
} ],
146
+ 'show-externals' => [ \&cmd_show_externals, "Show svn:externals listings",
147
+ { 'revision|r=i' => \$_revision
148
+ } ],
149
'multi-fetch' => [ \&cmd_multi_fetch,
150
"Deprecated alias for $0 fetch --all",
151
{ 'revision|r=s' => \$_revision, %fc_opts } ],
@@ -567,6 +570,21 @@ sub cmd_show_ignore {
570
});
571
}
572
573
+sub cmd_show_externals {
574
+ my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
575
+ $gs ||= Git::SVN->new;
576
+ my $r = (defined $_revision ? $_revision : $gs->ra->get_latest_revnum);
577
+ $gs->prop_walk($gs->{path}, $r, sub {
578
+ my ($gs, $path, $props) = @_;
579
+ print STDOUT "\n# $path\n";
580
+ my $s = $props->{'svn:externals'} or return;
581
+ $s =~ s/[\r\n]+/\n/g;
582
+ chomp $s;
583
+ $s =~ s#^#$path#gm;
584
+ print STDOUT "$s\n";
585
+ });
586
+}
587
+
588
sub cmd_create_ignore {
589
my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
590
$gs ||= Git::SVN->new;