Skip to content

Commit

Permalink
Add --no-rebase option to git-svn dcommit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Karl Hasselström authored and Junio C Hamano committed May 4, 2007
1 parent cc1793e commit 171af11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ and have no uncommitted changes.
alternative to HEAD.
This is advantageous over 'set-tree' (below) because it produces
cleaner, more linear history.
+
--no-rebase;;
After committing, do not rebase or reset.
--

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

sub cmd_find_rev {
Expand Down

0 comments on commit 171af11

Please sign in to comment.