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>
This commit is contained in:
parent
d2a9a87b8a
commit
dd31da2fdc
@ -57,11 +57,13 @@ See '<<fetch-args,Additional Fetch Arguments>>' if you are interested in
|
|||||||
manually joining branches on commit.
|
manually joining branches on commit.
|
||||||
|
|
||||||
'dcommit'::
|
'dcommit'::
|
||||||
Commit all diffs from the current HEAD directly to the SVN
|
Commit all diffs from a specified head directly to the SVN
|
||||||
repository, and then rebase or reset (depending on whether or
|
repository, and then rebase or reset (depending on whether or
|
||||||
not there is a diff between SVN and HEAD). It is recommended
|
not there is a diff between SVN and head). It is recommended
|
||||||
that you run git-svn fetch and rebase (not pull) your commits
|
that you run git-svn fetch and rebase (not pull) your commits
|
||||||
against the latest changes in the SVN repository.
|
against the latest changes in the SVN repository.
|
||||||
|
An optional command-line argument may be specified as an
|
||||||
|
alternative to HEAD.
|
||||||
This is advantageous over 'commit' (below) because it produces
|
This is advantageous over 'commit' (below) because it produces
|
||||||
cleaner, more linear history.
|
cleaner, more linear history.
|
||||||
|
|
||||||
|
11
git-svn.perl
11
git-svn.perl
@ -604,8 +604,9 @@ sub commit_lib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub dcommit {
|
sub dcommit {
|
||||||
|
my $head = shift || 'HEAD';
|
||||||
my $gs = "refs/remotes/$GIT_SVN";
|
my $gs = "refs/remotes/$GIT_SVN";
|
||||||
chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD"));
|
chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..$head"));
|
||||||
my $last_rev;
|
my $last_rev;
|
||||||
foreach my $d (reverse @refs) {
|
foreach my $d (reverse @refs) {
|
||||||
if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
|
if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
|
||||||
@ -632,16 +633,16 @@ sub dcommit {
|
|||||||
}
|
}
|
||||||
return if $_dry_run;
|
return if $_dry_run;
|
||||||
fetch();
|
fetch();
|
||||||
my @diff = safe_qx(qw/git-diff-tree HEAD/, $gs);
|
my @diff = safe_qx('git-diff-tree', $head, $gs);
|
||||||
my @finish;
|
my @finish;
|
||||||
if (@diff) {
|
if (@diff) {
|
||||||
@finish = qw/rebase/;
|
@finish = qw/rebase/;
|
||||||
push @finish, qw/--merge/ if $_merge;
|
push @finish, qw/--merge/ if $_merge;
|
||||||
push @finish, "--strategy=$_strategy" if $_strategy;
|
push @finish, "--strategy=$_strategy" if $_strategy;
|
||||||
print STDERR "W: HEAD and $gs differ, using @finish:\n", @diff;
|
print STDERR "W: $head and $gs differ, using @finish:\n", @diff;
|
||||||
} else {
|
} else {
|
||||||
print "No changes between current HEAD and $gs\n",
|
print "No changes between current $head and $gs\n",
|
||||||
"Hard resetting to the latest $gs\n";
|
"Resetting to the latest $gs\n";
|
||||||
@finish = qw/reset --mixed/;
|
@finish = qw/reset --mixed/;
|
||||||
}
|
}
|
||||||
sys('git', @finish, $gs);
|
sys('git', @finish, $gs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user