Skip to content

Commit dd31da2

Browse files
Eric WongJunio C Hamano
authored andcommitted
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>
1 parent d2a9a87 commit dd31da2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Documentation/git-svn.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ See '<<fetch-args,Additional Fetch Arguments>>' if you are interested in
5757
manually joining branches on commit.
5858

5959
'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
6161
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
6363
that you run git-svn fetch and rebase (not pull) your commits
6464
against the latest changes in the SVN repository.
65+
An optional command-line argument may be specified as an
66+
alternative to HEAD.
6567
This is advantageous over 'commit' (below) because it produces
6668
cleaner, more linear history.
6769

git-svn.perl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,9 @@ sub commit_lib {
604604
}
605605

606606
sub dcommit {
607+
my $head = shift || 'HEAD';
607608
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"));
609610
my $last_rev;
610611
foreach my $d (reverse @refs) {
611612
if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
@@ -632,16 +633,16 @@ sub dcommit {
632633
}
633634
return if $_dry_run;
634635
fetch();
635-
my @diff = safe_qx(qw/git-diff-tree HEAD/, $gs);
636+
my @diff = safe_qx('git-diff-tree', $head, $gs);
636637
my @finish;
637638
if (@diff) {
638639
@finish = qw/rebase/;
639640
push @finish, qw/--merge/ if $_merge;
640641
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;
642643
} 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";
645646
@finish = qw/reset --mixed/;
646647
}
647648
sys('git', @finish, $gs);

0 commit comments

Comments
 (0)