# [PATCH] Add a --dry-run option to git-svn rebase

8 messages from 2008-05-19 to 2008-06-02. Participants: Seth Falcon, Toby Allsopp, toby.allsopp (toby.allsopp - NAVMAN), Eric Wong, Junio C Hamano.
Thread: https://gitlist.dev/t/13573

## Seth Falcon, 2008-05-19 14:20

Subject: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <1211206844-29842-1-git-send-email-seth@userprimary.net>
URL: https://gitlist.dev/e/1211206844-29842-1-git-send-email-seth%40userprimary.net
In-Reply-To: <3c20080519141036.GV396@ziti.local>

```
When working with multiple branches in an svn repository, it can be
useful to verify the svn repository and local tracking branch that will
be used for the rebase operation.

Signed-off-by: Seth Falcon <seth@userprimary.net>
---
 Documentation/git-svn.txt |    8 ++++++--
 git-svn.perl              |    6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index c6b56b4..5890028 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -342,11 +342,15 @@ Passed directly to git-rebase when using 'dcommit' if a
 -n::
 --dry-run::
 
-This is only used with the 'dcommit' command.
+This can be used with the 'dcommit' and 'rebase' commands.
 
-Print out the series of git arguments that would show
+For 'dcommit', print out the series of git arguments that would show
 which diffs would be committed to SVN.
 
+For 'rebase', display the local branch associated with the upstream svn
+repository associated with the current branch and the URL of svn
+repository that will be fetched from.
+
 --
 
 ADVANCED OPTIONS
diff --git a/git-svn.perl b/git-svn.perl
index 2c53f39..de52c12 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -176,6 +176,7 @@ my %cmd = (
 			  'strategy|s=s' => \$_strategy,
 			  'local|l' => \$_local,
 			  'fetch-all|all' => \$_fetch_all,
+                          'dryrun|n' => \$_dry_run,
 			  %fc_opts } ],
 	'commit-diff' => [ \&cmd_commit_diff,
 	                   'Commit a diff between two trees',
@@ -553,6 +554,11 @@ sub cmd_rebase {
 		die "Unable to determine upstream SVN information from ",
 		    "working tree history\n";
 	}
+        if ($_dry_run) {
+                print "remote-branch: " . $gs->refname . "\n";
+                print "svn-url: " . $url . "\n";
+                return;
+        }
 	if (command(qw/diff-index HEAD --/)) {
 		print STDERR "Cannot rebase with uncommited changes:\n";
 		command_noisy('status');
-- 
1.5.5.1.316.g377d9.dirty

```

## Toby Allsopp, 2008-05-20 00:19

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <87tzgtygh9.fsf@nav-akl-pcn-343.mitacad.com>
URL: https://gitlist.dev/e/87tzgtygh9.fsf%40nav-akl-pcn-343.mitacad.com
In-Reply-To: <1211206844-29842-1-git-send-email-seth@userprimary.net>

```
On Tue, May 20 2008, Seth Falcon wrote:

[...]

> diff --git a/git-svn.perl b/git-svn.perl
> index 2c53f39..de52c12 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -176,6 +176,7 @@ my %cmd = (
>  			  'strategy|s=s' => \$_strategy,
>  			  'local|l' => \$_local,
>  			  'fetch-all|all' => \$_fetch_all,
> +                          'dryrun|n' => \$_dry_run,

s/dryrun/dry-run/ perhaps?  Also, it looks like you've used spaces
instead of tabs.

Toby.

```

## toby.allsopp (toby.allsopp - NAVMAN), 2008-05-20 00:19

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <87hcctygah.fsf@nav-akl-pcn-343.mitacad.com>
URL: https://gitlist.dev/e/87hcctygah.fsf%40nav-akl-pcn-343.mitacad.com
In-Reply-To: <1211206844-29842-1-git-send-email-seth@userprimary.net>

```
[resending to correct Eric's email address]

On Tue, May 20 2008, Seth Falcon wrote:

[...]

> diff --git a/git-svn.perl b/git-svn.perl
> index 2c53f39..de52c12 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -176,6 +176,7 @@ my %cmd = (
>  			  'strategy|s=s' => \$_strategy,
>  			  'local|l' => \$_local,
>  			  'fetch-all|all' => \$_fetch_all,
> +                          'dryrun|n' => \$_dry_run,

s/dryrun/dry-run/ perhaps?  Also, it looks like you've used spaces
instead of tabs.

Toby.

```

## Seth Falcon, 2008-05-20 03:24

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <20080520032458.GF396@ziti.local>
URL: https://gitlist.dev/e/20080520032458.GF396%40ziti.local
In-Reply-To: <87hcctygah.fsf@nav-akl-pcn-343.mitacad.com>

```
* On 2008-05-20 at 12:19 +1200 toby.allsopp (toby.allsopp - NAVMAN) wrote:

> [resending to correct Eric's email address]

Sorry about that, typoed the address.

> s/dryrun/dry-run/ perhaps?  Also, it looks like you've used spaces
> instead of tabs.

I'll address both of those and resend, thanks.

+ seth

-- 
Seth Falcon | http://userprimary.net/user/

```

## Seth Falcon, 2008-05-20 03:29

Subject: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <1211254157-41316-1-git-send-email-seth@userprimary.net>
URL: https://gitlist.dev/e/1211254157-41316-1-git-send-email-seth%40userprimary.net
In-Reply-To: <87hcctygah.fsf@nav-akl-pcn-343.mitacad.com>

```
When working with multiple branches in an svn repository, it can be
useful to verify the svn repository and local tracking branch that will
be used for the rebase operation.

Signed-off-by: Seth Falcon <seth@userprimary.net>
---

Reworked to fix the spelling of dry-run and whitespace issues.

 Documentation/git-svn.txt |    8 ++++++--
 git-svn.perl              |    6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index c6b56b4..5890028 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -342,11 +342,15 @@ Passed directly to git-rebase when using 'dcommit' if a
 -n::
 --dry-run::
 
-This is only used with the 'dcommit' command.
+This can be used with the 'dcommit' and 'rebase' commands.
 
-Print out the series of git arguments that would show
+For 'dcommit', print out the series of git arguments that would show
 which diffs would be committed to SVN.
 
+For 'rebase', display the local branch associated with the upstream svn
+repository associated with the current branch and the URL of svn
+repository that will be fetched from.
+
 --
 
 ADVANCED OPTIONS
diff --git a/git-svn.perl b/git-svn.perl
index 2c53f39..9c60ef4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -176,6 +176,7 @@ my %cmd = (
 			  'strategy|s=s' => \$_strategy,
 			  'local|l' => \$_local,
 			  'fetch-all|all' => \$_fetch_all,
+			  'dry-run|n' => \$_dry_run,
 			  %fc_opts } ],
 	'commit-diff' => [ \&cmd_commit_diff,
 	                   'Commit a diff between two trees',
@@ -553,6 +554,11 @@ sub cmd_rebase {
 		die "Unable to determine upstream SVN information from ",
 		    "working tree history\n";
 	}
+	if ($_dry_run) {
+		print "remote-branch: " . $gs->refname . "\n";
+		print "svn-url: " . $url . "\n";
+		return;
+	}
 	if (command(qw/diff-index HEAD --/)) {
 		print STDERR "Cannot rebase with uncommited changes:\n";
 		command_noisy('status');
-- 
1.5.5.1.316.g377d9.dirty

```

## Eric Wong, 2008-06-01 10:13

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <20080601101304.GC16064@hand.yhbt.net>
URL: https://gitlist.dev/e/20080601101304.GC16064%40hand.yhbt.net
In-Reply-To: <20080530171831.GB76080@ziti.local>

```
Seth Falcon <seth@userprimary.net> wrote:
> Hi Eric,
> 
> I think this may have slipped by without your notice as I gather
> things have been busy for you.
> 
> Could you take a look at this patch and let me know if you like
> it/hate it/have a suggestion?
> 
> My motivation was wanting to automate some commit rewritting and
> wanting a script to be able to determine what the local upstream
> branch is...

This patch looks reasonable to me.
Acked-by: Eric Wong <normalperson@yhbt.net>

> * On 2008-05-19 at 20:29 -0700 Seth Falcon wrote:
> > @@ -553,6 +554,11 @@ sub cmd_rebase {
> >  		die "Unable to determine upstream SVN information from ",
> >  		    "working tree history\n";
> >  	}
> > +	if ($_dry_run) {
> > +		print "remote-branch: " . $gs->refname . "\n";
> > +		print "svn-url: " . $url . "\n";
> > +		return;
> > +	}
> >  	if (command(qw/diff-index HEAD --/)) {
> >  		print STDERR "Cannot rebase with uncommited changes:\n";
> >  		command_noisy('status');

One minor nit is 'url' not being capitalized in the output.  Perhaps:

	Remote Branch: foo
	SVN URL: http://asdf/foo/trunk


Which would make it consistent with 'git svn info' using spaces:

RFC822-style headers would be alright, too.

	Remote-Branch: foo
	SVN-URL: http://asdf/foo/trunk

I do however harbor a deep dislike of camel-case
(used by 'git log --pretty=fuller' and .git/config).

	RemoteBranch: foo
	SvnUrl: http://asdf/foo/trunk


Hmm, I don't think I've even _noticed_ a real bike shed in decades.
Perhaps they should be painted purple with yellow polkadots and have the
words "BIKE SHED" on a flashing neon sign.

-- 
Eric Wong

```

## Seth Falcon, 2008-06-02 04:56

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <20080602045639.GB647@ziti.local>
URL: https://gitlist.dev/e/20080602045639.GB647%40ziti.local
In-Reply-To: <20080601101304.GC16064@hand.yhbt.net>

```
* On 2008-06-01 at 03:13 -0700 Eric Wong wrote:
> This patch looks reasonable to me.
> Acked-by: Eric Wong <normalperson@yhbt.net>

> One minor nit is 'url' not being capitalized in the output.
> Perhaps:

Any of the suggested bike shed colors are fine by me :-) I'll assume
the patch is fine as-is, or will be edited by Junio before being
applied, unless I hear otherwise.


-- 
Seth Falcon | http://userprimary.net/user/

```

## Junio C Hamano, 2008-06-02 05:37

Subject: Re: [PATCH] Add a --dry-run option to git-svn rebase
Message-ID: <7v7id89z3j.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7id89z3j.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080602045639.GB647@ziti.local>

```
Seth Falcon <seth@userprimary.net> writes:

> * On 2008-06-01 at 03:13 -0700 Eric Wong wrote:
>> This patch looks reasonable to me.
>> Acked-by: Eric Wong <normalperson@yhbt.net>
>
>> One minor nit is 'url' not being capitalized in the output.
>> Perhaps:
>
> Any of the suggested bike shed colors are fine by me :-) I'll assume
> the patch is fine as-is, or will be edited by Junio before being
> applied, unless I hear otherwise.

Yeah, I've queued the patch.  Thanks, both.

```
