@matheusbsbs / matheus-bagliano / commits / dd31da2fdc
Fork 0

git-svn: allow dcommit to take an alternate head

Previously dcommit would unconditionally commit all patches up-to and including the current HEAD. Now if an optional command-line argument is specified, it will only commit up to the specified revision. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Dec 12, 2006 at 14:47 UTC dd31da2fdc199132c9fd42023aea5b33672d73cc
2 files changed +10 -7
Documentation/git-svn.txt
+4 -2
@@ -57,11 +57,13 @@ See '<<fetch-args,Additional Fetch Arguments>>' if you are interested in
57 manually joining branches on commit.
58
59 'dcommit'::
60 - Commit all diffs from the current HEAD directly to the SVN
60 + Commit all diffs from a specified head directly to the SVN
61 repository, and then rebase or reset (depending on whether or
62 - not there is a diff between SVN and HEAD). It is recommended
62 + not there is a diff between SVN and head). It is recommended
63 that you run git-svn fetch and rebase (not pull) your commits
64 against the latest changes in the SVN repository.
65 + An optional command-line argument may be specified as an
66 + alternative to HEAD.
67 This is advantageous over 'commit' (below) because it produces
68 cleaner, more linear history.
69
git-svn.perl
+6 -5
@@ -604,8 +604,9 @@ sub commit_lib {
604 }
605
606 sub dcommit {
607 + my $head = shift || 'HEAD';
608 my $gs = "refs/remotes/$GIT_SVN";
608 - chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD"));
609 + chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..$head"));
610 my $last_rev;
611 foreach my $d (reverse @refs) {
612 if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
@@ -632,16 +633,16 @@ sub dcommit {
633 }
634 return if $_dry_run;
635 fetch();
635 - my @diff = safe_qx(qw/git-diff-tree HEAD/, $gs);
636 + my @diff = safe_qx('git-diff-tree', $head, $gs);
637 my @finish;
638 if (@diff) {
639 @finish = qw/rebase/;
640 push @finish, qw/--merge/ if $_merge;
641 push @finish, "--strategy=$_strategy" if $_strategy;
641 - print STDERR "W: HEAD and $gs differ, using @finish:\n", @diff;
642 + print STDERR "W: $head and $gs differ, using @finish:\n", @diff;
643 } else {
643 - print "No changes between current HEAD and $gs\n",
644 - "Hard resetting to the latest $gs\n";
644 + print "No changes between current $head and $gs\n",
645 + "Resetting to the latest $gs\n";
646 @finish = qw/reset --mixed/;
647 }
648 sys('git', @finish, $gs);