]> Pileus Git - ~andy/git/commitdiff
git-svn: add fetch --parent option
authorJason Merrill <jason@redhat.com>
Mon, 6 Apr 2009 20:37:59 +0000 (16:37 -0400)
committerEric Wong <normalperson@yhbt.net>
Sun, 12 Apr 2009 00:53:52 +0000 (17:53 -0700)
Signed-off-by: Jason Merrill <jason@redhat.com>
Acked-By: Eric Wong <normalperson@yhbt.net>
Documentation/git-svn.txt
git-svn.perl

index b7b1af813d79a88aab3d74a39b7a63570c44871c..85b2c8da5d427d1823efc3ba0f0e10a093975267 100644 (file)
@@ -97,6 +97,9 @@ COMMANDS
        makes 'git-log' (even without --date=local) show the same times
        that `svn log` would in the local timezone.
 
+--parent;;
+       Fetch only from the SVN parent of the current HEAD.
+
 This doesn't interfere with interoperating with the Subversion
 repository you cloned from, but if you wish for your local Git
 repository to be able to interoperate with someone else's local Git
index d9197989d2e063ecf0bbbac143a046f8de79ce52..cb718b8519f1f1d6704154b839c6a14b63776274 100755 (executable)
@@ -63,7 +63,7 @@ $sha1_short = qr/[a-f\d]{4,40}/;
 my ($_stdin, $_help, $_edit,
        $_message, $_file,
        $_template, $_shared,
-       $_version, $_fetch_all, $_no_rebase,
+       $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
        $_merge, $_strategy, $_dry_run, $_local,
        $_prefix, $_no_checkout, $_url, $_verbose,
        $_git_format, $_commit_url, $_tag);
@@ -112,6 +112,7 @@ my %cmd = (
        fetch => [ \&cmd_fetch, "Download new revisions from SVN",
                        { 'revision|r=s' => \$_revision,
                          'fetch-all|all' => \$_fetch_all,
+                         'parent|p' => \$_fetch_parent,
                           %fc_opts } ],
        clone => [ \&cmd_clone, "Initialize and fetch revisions",
                        { 'revision|r=s' => \$_revision,
@@ -381,12 +382,21 @@ sub cmd_fetch {
        }
        my ($remote) = @_;
        if (@_ > 1) {
-               die "Usage: $0 fetch [--all] [svn-remote]\n";
+               die "Usage: $0 fetch [--all] [--parent] [svn-remote]\n";
        }
-       $remote ||= $Git::SVN::default_repo_id;
-       if ($_fetch_all) {
+       if ($_fetch_parent) {
+               my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
+               unless ($gs) {
+                       die "Unable to determine upstream SVN information from ",
+                           "working tree history\n";
+               }
+               # just fetch, don't checkout.
+               $_no_checkout = 'true';
+               $_fetch_all ? $gs->fetch_all : $gs->fetch;
+       } elsif ($_fetch_all) {
                cmd_multi_fetch();
        } else {
+               $remote ||= $Git::SVN::default_repo_id;
                Git::SVN::fetch_all($remote, Git::SVN::read_all_remotes());
        }
 }