git-svn: add fetch --parent option
Signed-off-by: Jason Merrill <jason@redhat.com> Acked-By: Eric Wong <normalperson@yhbt.net>
Jason Merrill committed
Apr 6, 2009 at 16:37 UTC
c2abd83fea0c332e907f5bc23bea4eeca091a86b
2 files changed
+17
-4
Documentation/git-svn.txt
+3
@@ -97,6 +97,9 @@ COMMANDS
97
makes 'git-log' (even without --date=local) show the same times
98
that `svn log` would in the local timezone.
99
100
+--parent;;
101
+ Fetch only from the SVN parent of the current HEAD.
102
+
103
This doesn't interfere with interoperating with the Subversion
104
repository you cloned from, but if you wish for your local Git
105
repository to be able to interoperate with someone else's local Git
git-svn.perl
+14
-4
@@ -63,7 +63,7 @@ $sha1_short = qr/[a-f\d]{4,40}/;
63
my ($_stdin, $_help, $_edit,
64
$_message, $_file,
65
$_template, $_shared,
66
- $_version, $_fetch_all, $_no_rebase,
66
+ $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
67
$_merge, $_strategy, $_dry_run, $_local,
68
$_prefix, $_no_checkout, $_url, $_verbose,
69
$_git_format, $_commit_url, $_tag);
@@ -112,6 +112,7 @@ my %cmd = (
112
fetch => [ \&cmd_fetch, "Download new revisions from SVN",
113
{ 'revision|r=s' => \$_revision,
114
'fetch-all|all' => \$_fetch_all,
115
+ 'parent|p' => \$_fetch_parent,
116
%fc_opts } ],
117
clone => [ \&cmd_clone, "Initialize and fetch revisions",
118
{ 'revision|r=s' => \$_revision,
@@ -381,12 +382,21 @@ sub cmd_fetch {
382
}
383
my ($remote) = @_;
384
if (@_ > 1) {
384
- die "Usage: $0 fetch [--all] [svn-remote]\n";
385
+ die "Usage: $0 fetch [--all] [--parent] [svn-remote]\n";
386
}
386
- $remote ||= $Git::SVN::default_repo_id;
387
- if ($_fetch_all) {
387
+ if ($_fetch_parent) {
388
+ my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
389
+ unless ($gs) {
390
+ die "Unable to determine upstream SVN information from ",
391
+ "working tree history\n";
392
+ }
393
+ # just fetch, don't checkout.
394
+ $_no_checkout = 'true';
395
+ $_fetch_all ? $gs->fetch_all : $gs->fetch;
396
+ } elsif ($_fetch_all) {
397
cmd_multi_fetch();
398
} else {
399
+ $remote ||= $Git::SVN::default_repo_id;
400
Git::SVN::fetch_all($remote, Git::SVN::read_all_remotes());
401
}
402
}