# PATCH: git-svn: support rebase --preserve-merges

2 messages from 2012-05-15 to 2012-05-16. Participants: Avishay Lavie, Eric Wong.
Thread: https://gitlist.dev/t/30532

## Avishay Lavie, 2012-05-15 09:09

Subject: PATCH: git-svn: support rebase --preserve-merges
Message-ID: <CAHkK2boHtwbpbfQiqWFWn3BaGfJkojVPLisaghY256m+irE3ow@mail.gmail.com>
URL: https://gitlist.dev/e/CAHkK2boHtwbpbfQiqWFWn3BaGfJkojVPLisaghY256m%2BirE3ow%40mail.gmail.com

```
From: Avishay Lavie <avishay.lavie@gmail.com>
Date: Tue, 15 May 2012 11:45:50 +0300
Subject: [PATCH] git-svn: support rebase --preserve-merges

When git svn rebase is performed after an unpushed merge, the
rebase operation follows both parents and replays both the user's
local commits and those from the merged branch. This is usually
not the intended behavior.
This patch adds support for the --preserve-merges/-p flag which
allows for a better workflow by re-applying merge commits as merges.

Signed-off-by: Avishay Lavie <avishay.lavie@gmail.com>
---
 Documentation/git-svn.txt |    2 ++
 git-svn.perl              |    4 +++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 34ee785..0d52997 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -572,6 +572,8 @@ config key: svn.repackflags
 --merge::
 -s<strategy>::
 --strategy=<strategy>::
+-p::
+--preserve-merges::
 	These are only used with the 'dcommit' and 'rebase' commands.
 +
 Passed directly to 'git rebase' when using 'dcommit' if a
diff --git a/git-svn.perl b/git-svn.perl
index ca038ec..e86d60b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -84,7 +84,7 @@ my ($_stdin, $_help, $_edit,
 	$_message, $_file, $_branch_dest,
 	$_template, $_shared,
 	$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
-	$_merge, $_strategy, $_dry_run, $_local,
+	$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
 	$_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
 $Git::SVN::_follow_parent = 1;
@@ -233,6 +233,7 @@ my %cmd = (
 			  'local|l' => \$_local,
 			  'fetch-all|all' => \$_fetch_all,
 			  'dry-run|n' => \$_dry_run,
+			  'preserve-merges|p' => \$_preserve_merges
 			  %fc_opts } ],
 	'commit-diff' => [ \&cmd_commit_diff,
 	                   'Commit a diff between two trees',
@@ -1570,6 +1571,7 @@ sub rebase_cmd {
 	push @cmd, '-v' if $_verbose;
 	push @cmd, qw/--merge/ if $_merge;
 	push @cmd, "--strategy=$_strategy" if $_strategy;
+	push @cmd, "--preserve-merges" if $_preserve_merges;
 	@cmd;
 }

-- 
1.7.9.msysgit.0

```

## Eric Wong, 2012-05-16 00:36

Subject: Re: PATCH: git-svn: support rebase --preserve-merges
Message-ID: <20120516003623.GA7283@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20120516003623.GA7283%40dcvr.yhbt.net
In-Reply-To: <CAHkK2boHtwbpbfQiqWFWn3BaGfJkojVPLisaghY256m+irE3ow@mail.gmail.com>

```
Avishay Lavie <avishay.lavie@gmail.com> wrote:
> +++ b/git-svn.perl
> @@ -233,6 +233,7 @@ my %cmd = (
>  			  'local|l' => \$_local,
>  			  'fetch-all|all' => \$_fetch_all,
>  			  'dry-run|n' => \$_dry_run,
> +			  'preserve-merges|p' => \$_preserve_merges
>  			  %fc_opts } ],
>  	'commit-diff' => [ \&cmd_commit_diff,
>  	                   'Commit a diff between two trees',

You're missing a comma in the above hunk, but otherwise your patch
looks trivially correct (no need to resend, I'll fix up on my end).

```
