Browse Source

Add --no-rebase option to git-svn dcommit

git-svn dcommit exports commits to Subversion, then imports them back
to git again, and last but not least rebases or resets HEAD to the
last of the new commits. I guess this rebasing is convenient when
using just git, but when the commits to be exported are managed by
StGIT, it's really annoying. So add an option to disable this
behavior. And document it, too!

Signed-off-by: Karl Hasselström <kha@treskal.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Karl Hasselström 18 years ago committed by Junio C Hamano
parent
commit
171af11082
  1. 3
      Documentation/git-svn.txt
  2. 33
      git-svn.perl

3
Documentation/git-svn.txt

@ -119,6 +119,9 @@ and have no uncommitted changes.
alternative to HEAD. alternative to HEAD.
This is advantageous over 'set-tree' (below) because it produces This is advantageous over 'set-tree' (below) because it produces
cleaner, more linear history. cleaner, more linear history.
+
--no-rebase;;
After committing, do not rebase or reset.
-- --


'log':: 'log'::

33
git-svn.perl

@ -55,7 +55,7 @@ $sha1_short = qr/[a-f\d]{4,40}/;
my ($_stdin, $_help, $_edit, my ($_stdin, $_help, $_edit,
$_message, $_file, $_message, $_file,
$_template, $_shared, $_template, $_shared,
$_version, $_fetch_all, $_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local, $_merge, $_strategy, $_dry_run, $_local,
$_prefix, $_no_checkout, $_verbose); $_prefix, $_no_checkout, $_verbose);
$Git::SVN::_follow_parent = 1; $Git::SVN::_follow_parent = 1;
@ -114,6 +114,7 @@ my %cmd = (
'verbose|v' => \$_verbose, 'verbose|v' => \$_verbose,
'dry-run|n' => \$_dry_run, 'dry-run|n' => \$_dry_run,
'fetch-all|all' => \$_fetch_all, 'fetch-all|all' => \$_fetch_all,
'no-rebase' => \$_no_rebase,
%cmt_opts, %fc_opts } ], %cmt_opts, %fc_opts } ],
'set-tree' => [ \&cmd_set_tree, 'set-tree' => [ \&cmd_set_tree,
"Set an SVN repository to a git tree-ish", "Set an SVN repository to a git tree-ish",
@ -413,21 +414,23 @@ sub cmd_dcommit {
return; return;
} }
$_fetch_all ? $gs->fetch_all : $gs->fetch; $_fetch_all ? $gs->fetch_all : $gs->fetch;
# we always want to rebase against the current HEAD, not any unless ($_no_rebase) {
# head that was passed to us # we always want to rebase against the current HEAD, not any
my @diff = command('diff-tree', 'HEAD', $gs->refname, '--'); # head that was passed to us
my @finish; my @diff = command('diff-tree', 'HEAD', $gs->refname, '--');
if (@diff) { my @finish;
@finish = rebase_cmd(); if (@diff) {
print STDERR "W: HEAD and ", $gs->refname, " differ, ", @finish = rebase_cmd();
"using @finish:\n", "@diff"; print STDERR "W: HEAD and ", $gs->refname, " differ, ",
} else { "using @finish:\n", "@diff";
print "No changes between current HEAD and ", } else {
$gs->refname, "\nResetting to the latest ", print "No changes between current HEAD and ",
$gs->refname, "\n"; $gs->refname, "\nResetting to the latest ",
@finish = qw/reset --mixed/; $gs->refname, "\n";
@finish = qw/reset --mixed/;
}
command_noisy(@finish, $gs->refname);
} }
command_noisy(@finish, $gs->refname);
} }


sub cmd_find_rev { sub cmd_find_rev {

Loading…
Cancel
Save