threads / patch / 9030

patchgit-svn init/clone --stdlayout option to default-init trunk/tags/branches

Subject: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

## tl;dr

7 messages between Jul 14, 2007 and Aug 23, 2007. Diffs are folded; open one to read it.

replies: 6people: 2as markdown or json

martin f. krafft· Jul 14, 2007, 09:25 UTC · lore

The --stdlayout option to git-svn init/clone initialises the default Subversion values of trunk,tags,branches: -T trunk -b branches -t tags. If any of the -T/-t/-b options are given in addition, they are given preference.

Signed-off-by: martin f. krafft <madduck@madduck.net>
---
 Documentation/git-svn.txt |    6 +++++-
 git-svn.perl              |   11 +++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
Show changes to 2 files +14 −3

Documentation/git-svn.txt, git-svn.perl

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 0a210e4..9e74b27 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -44,10 +44,14 @@ COMMANDS
 --tags=<tags_subdir>;;
 -b<branches_subdir>;;
 --branches=<branches_subdir>;;
+--stdlayout;;
 	These are optional command-line options for init.  Each of
 	these flags can point to a relative repository path
 	(--tags=project/tags') or a full url
-	(--tags=https://foo.org/project/tags)
+	(--tags=https://foo.org/project/tags). The option --stdlayout is
+	a shorthand way of setting trunk,tags,branches as the relative paths,
+	which is the Subversion default. If any of the other options are given
+	as well, they take precedence.
 --no-metadata;;
 	Set the 'noMetadata' option in the [svn-remote] config.
 --use-svm-props;;
diff --git a/git-svn.perl b/git-svn.perl
index b3dffcc..affba8e 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -77,11 +77,12 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
 		   \$Git::SVN::_repack_flags,
 		%remote_opts );
 
-my ($_trunk, $_tags, $_branches);
+my ($_trunk, $_tags, $_branches, $_stdlayout);
 my %icv;
 my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
                   'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
                   'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
+                  'stdlayout' => \$_stdlayout,
                   'minimize-url|m' => \$Git::SVN::_minimize_url,
 		  'no-metadata' => sub { $icv{noMetadata} = 1 },
 		  'use-svm-props' => sub { $icv{useSvmProps} = 1 },
@@ -292,7 +293,8 @@ sub init_subdir {
 sub cmd_clone {
 	my ($url, $path) = @_;
 	if (!defined $path &&
-	    (defined $_trunk || defined $_branches || defined $_tags) &&
+	    (defined $_trunk || defined $_branches || defined $_tags ||
+		defined $_stdlayout) &&
 	    $url !~ m#^[a-z\+]+://#) {
 		$path = $url;
 	}
@@ -302,6 +304,11 @@ sub cmd_clone {
 }
 
 sub cmd_init {
+        if (defined $_stdlayout) {
+          $_trunk = 'trunk' if (!defined $_trunk);
+          $_tags = 'tags' if (!defined $_tags);
+          $_branches = 'branches' if (!defined $_branches);
+        }
 	if (defined $_trunk || defined $_branches || defined $_tags) {
 		return cmd_multi_init(@_);
 	}
-- 
1.5.3.rc1.9.gf029
Eric Wong· Jul 14, 2007, 10:50 UTC · re: martin f. krafft · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

"martin f. krafft" <madduck@madduck.net> wrote:
Show 6 quoted lines
> The --stdlayout option to git-svn init/clone initialises the default
> Subversion values of trunk,tags,branches: -T trunk -b branches -t tags.
> If any of the -T/-t/-b options are given in addition, they are given
> preference.
> 
> Signed-off-by: martin f. krafft <madduck@madduck.net>

Thanks. I've been meaning to do this myself, but keep on putting it off...

This looks good and useful, but can I also have a shorthand "-s" for this, too? I'm lazy, thanks :)

Also, nitpicking, there's been some whitespace damage:

I use tab characters for indentation, and (should be using) spaces for alignment.

Show 43 quoted lines
> ---
>  Documentation/git-svn.txt |    6 +++++-
>  git-svn.perl              |   11 +++++++++--
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
> index 0a210e4..9e74b27 100644
> --- a/Documentation/git-svn.txt
> +++ b/Documentation/git-svn.txt
> @@ -44,10 +44,14 @@ COMMANDS
>  --tags=<tags_subdir>;;
>  -b<branches_subdir>;;
>  --branches=<branches_subdir>;;
> +--stdlayout;;
>  	These are optional command-line options for init.  Each of
>  	these flags can point to a relative repository path
>  	(--tags=project/tags') or a full url
> -	(--tags=https://foo.org/project/tags)
> +	(--tags=https://foo.org/project/tags). The option --stdlayout is
> +	a shorthand way of setting trunk,tags,branches as the relative paths,
> +	which is the Subversion default. If any of the other options are given
> +	as well, they take precedence.
>  --no-metadata;;
>  	Set the 'noMetadata' option in the [svn-remote] config.
>  --use-svm-props;;
> diff --git a/git-svn.perl b/git-svn.perl
> index b3dffcc..affba8e 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -77,11 +77,12 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
>  		   \$Git::SVN::_repack_flags,
>  		%remote_opts );
>  
> -my ($_trunk, $_tags, $_branches);
> +my ($_trunk, $_tags, $_branches, $_stdlayout);
>  my %icv;
>  my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
>                    'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
>                    'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
> +                  'stdlayout' => \$_stdlayout,
>                    'minimize-url|m' => \$Git::SVN::_minimize_url,
>  		  'no-metadata' => sub { $icv{noMetadata} = 1 },
>  		  'use-svm-props' => sub { $icv{useSvmProps} = 1 },

Yes, I'm not consistent myself with using spaces for alignment :( Thanks for using spaces here.

Show 7 quoted lines
> @@ -292,7 +293,8 @@ sub init_subdir {
>  sub cmd_clone {
>  	my ($url, $path) = @_;
>  	if (!defined $path &&
> -	    (defined $_trunk || defined $_branches || defined $_tags) &&
> +	    (defined $_trunk || defined $_branches || defined $_tags ||
> +		defined $_stdlayout) &&

The lines above and below use spaces for alignment, so this one should, definitely be using spaces after the initial tab too.

Show 12 quoted lines
>  	    $url !~ m#^[a-z\+]+://#) {
>  		$path = $url;
>  	}
> @@ -302,6 +304,11 @@ sub cmd_clone {
>  }
>  
>  sub cmd_init {
> +        if (defined $_stdlayout) {
> +          $_trunk = 'trunk' if (!defined $_trunk);
> +          $_tags = 'tags' if (!defined $_tags);
> +          $_branches = 'branches' if (!defined $_branches);
> +        }

Indentation is always done in tabs in git-svn. I *should* be using spaces for alignment but I myself have been sloppy :x

>  	if (defined $_trunk || defined $_branches || defined $_tags) {
>  		return cmd_multi_init(@_);
>  	}
-- 
Eric Wong
martin f krafft· Jul 14, 2007, 11:04 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

also sprach Eric Wong <normalperson@yhbt.net> [2007.07.14.1250 +0200]:
> This looks good and useful, but can I also have a  shorthand "-s" for
> this, too?  I'm lazy, thanks :)
Of course.
> Also, nitpicking, there's been some whitespace damage:
> 
> I use tab characters for indentation, and (should be using) spaces for
> alignment.
What's the difference? Or is it simply:
  no. of tabs:   int(column / 8)
  no. of spaces: column % 8
?

I am sorry, I tried to do it right, even paid attention to the tabs/spaces thing, but I guess I failed.

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
spamtraps: madduck.bogus@madduck.net
 
save the plankton - eat a whale.
Eric Wong· Jul 14, 2007, 11:34 UTC · re: martin f krafft · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

martin f krafft <madduck@madduck.net> wrote:
Show 15 quoted lines
> also sprach Eric Wong <normalperson@yhbt.net> [2007.07.14.1250 +0200]:
> > This looks good and useful, but can I also have a  shorthand "-s" for
> > this, too?  I'm lazy, thanks :)
> 
> Of course.
> 
> > Also, nitpicking, there's been some whitespace damage:
> > 
> > I use tab characters for indentation, and (should be using) spaces for
> > alignment.
> 
> What's the difference? Or is it simply:
> 
>   no. of tabs:   int(column / 8)
>   no. of spaces: column % 8

It's also easier/faster to navigate code with tabs since there are fewer characters to iterate over, less granular points for indentation, making it easier to to get to a desired indentation level.

The less granularity with tabs means I can avoid situations where where I wonder if I'm correctly aligned with other pieces of code. I even have auto-indent set, but occasionally with spaces (when I work on Ruby code) I still have problems with being off-by-one after editing something.

There's absolutely no way I can misalign a block of code when alignment granularity is 8 characters no matter how sleepy I get :)

I use tabs for indentation where they denote logically different code paths / nesting.

Spaces (for alignment, not indentation) are mainly aesthetic. I use them in spaces when I need finer control (usually long conditionals in if-statements that are wrapped).

Tabs can also be easily reconfigured in editors to change the amount of screen real estate they consume. Not really useful in git-svn since I keep it <80 columns anyways.

> I am sorry, I tried to do it right, even paid attention to the
> tabs/spaces thing, but I guess I failed.

No worries. The maintainers here are also very picky about trailing whitespace and spaces that appear before tab characters, too and I became much more disciplined about that myself the past year.

I have highlighting search set in my editor (vim :set hls) and usually just search for spaces vs tabs to make sure I'm clean.

Of course, maintaining a consistent whitespace style helps a *lot* with the git/Linux patch exchange development style because it avoids needless patch application conflicts that arise from whitespace differences.

-- 
Eric Wong
martin f krafft· Jul 14, 2007, 12:04 UTC · re: Eric Wong · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

also sprach Eric Wong <normalperson@yhbt.net> [2007.07.14.1334 +0200]:
> I have highlighting search set in my editor (vim :set hls)
> and usually just search for spaces vs tabs to make sure I'm clean.
Try:
  :se lcs=tab:>-,trail,-
  augroup listinsert
    autocmd InsertEnter * set nolist
    autocmd InsertLeave * set list
  augroup end
> Of course, maintaining a consistent whitespace style helps a *lot*
> with the git/Linux patch exchange development style because it
> avoids needless patch application conflicts that arise from
> whitespace differences.

Using tabs also makes it impossible to X-cut-paste patches from emails; you *have* to use git-am and/or a temporary file, which i don't like at all.

But thanks for the explanation.
-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
spamtraps: madduck.bogus@madduck.net
 
Most Intelligent Customers Realise Our Software Only Fools Them.
Eric Wong· Jul 14, 2007, 20:38 UTC · re: martin f krafft · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

martin f krafft <madduck@madduck.net> wrote:
Show 7 quoted lines
> also sprach Eric Wong <normalperson@yhbt.net> [2007.07.14.1334 +0200]:
> > I have highlighting search set in my editor (vim :set hls)
> > and usually just search for spaces vs tabs to make sure I'm clean.
> 
> Try:
> 
>   :se lcs=tab:>-,trail,-
That didn't work, this does:
    :se lcs=tab:>-,trail:-
>   augroup listinsert
>     autocmd InsertEnter * set nolist
>     autocmd InsertLeave * set list
>   augroup end

Eep. Too confusing ;) I have my hls color set to be a red underscore (which nothing else in my syntax higlighting uses), so it's less intrusive for me.

Show 8 quoted lines
> > Of course, maintaining a consistent whitespace style helps a *lot*
> > with the git/Linux patch exchange development style because it
> > avoids needless patch application conflicts that arise from
> > whitespace differences.
> 
> Using tabs also makes it impossible to X-cut-paste patches from
> emails; you *have* to use git-am and/or a temporary file, which
> i don't like at all.

Ah. I that's one of the reasons I rarely use X-cut-paste for multi-line strings.

When I apply patches with or without git-am from email, I just start mutt inside the working source directory I'm in, and from the mutt index I spawn vim to edit any email (just hit 'e'), go into visual mode, select the part I want to apply and pipe that to whatever patch application program I want to use, and :q! out of vim.

-- 
Eric Wong
Eric Wong· Aug 23, 2007, 06:10 UTC · re: martin f. krafft · lore

Re: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

Here's a cleaned up version of this patch with my tweaks.
>From f5b6da6bc4e2d879ca200993f0d3806486e8fb21 Mon Sep 17 00:00:00 2001
From: martin f. krafft <madduck@madduck.net>
Date: Sat, 14 Jul 2007 11:25:28 +0200
Subject: [PATCH] git-svn init/clone --stdlayout option to default-init trunk/tags/branches

The --stdlayout option to git-svn init/clone initialises the default Subversion values of trunk,tags,branches: -T trunk -b branches -t tags. If any of the -T/-t/-b options are given in addition, they are given preference.

[ew: fixed whitespace and added "-s" shortcut]
Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 Documentation/git-svn.txt |    7 ++++++-
 git-svn.perl              |   11 +++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
Show changes to 2 files +15 −3

Documentation/git-svn.txt, git-svn.perl

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index fbc5887..3e2a63b 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -44,10 +44,15 @@ COMMANDS
 --tags=<tags_subdir>;;
 -b<branches_subdir>;;
 --branches=<branches_subdir>;;
+-s;;
+--stdlayout;;
 	These are optional command-line options for init.  Each of
 	these flags can point to a relative repository path
 	(--tags=project/tags') or a full url
-	(--tags=https://foo.org/project/tags)
+	(--tags=https://foo.org/project/tags). The option --stdlayout is
+	a shorthand way of setting trunk,tags,branches as the relative paths,
+	which is the Subversion default. If any of the other options are given
+	as well, they take precedence.
 --no-metadata;;
 	Set the 'noMetadata' option in the [svn-remote] config.
 --use-svm-props;;
diff --git a/git-svn.perl b/git-svn.perl
index 7a8ffd5..4e325b7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -77,11 +77,12 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
 		   \$Git::SVN::_repack_flags,
 		%remote_opts );
 
-my ($_trunk, $_tags, $_branches);
+my ($_trunk, $_tags, $_branches, $_stdlayout);
 my %icv;
 my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
                   'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
                   'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
+                  'stdlayout|s' => \$_stdlayout,
                   'minimize-url|m' => \$Git::SVN::_minimize_url,
 		  'no-metadata' => sub { $icv{noMetadata} = 1 },
 		  'use-svm-props' => sub { $icv{useSvmProps} = 1 },
@@ -292,7 +293,8 @@ sub init_subdir {
 sub cmd_clone {
 	my ($url, $path) = @_;
 	if (!defined $path &&
-	    (defined $_trunk || defined $_branches || defined $_tags) &&
+	    (defined $_trunk || defined $_branches || defined $_tags ||
+	     defined $_stdlayout) &&
 	    $url !~ m#^[a-z\+]+://#) {
 		$path = $url;
 	}
@@ -302,6 +304,11 @@ sub cmd_clone {
 }
 
 sub cmd_init {
+	if (defined $_stdlayout) {
+		$_trunk = 'trunk' if (!defined $_trunk);
+		$_tags = 'tags' if (!defined $_tags);
+		$_branches = 'branches' if (!defined $_branches);
+	}
 	if (defined $_trunk || defined $_branches || defined $_tags) {
 		return cmd_multi_init(@_);
 	}
-- 
Eric Wong

← back to recent threads