git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[MONKEY PATCH] git-svn: allow two branch configurations

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 18, 2009, 14:31 UTC
Message-ID
<1245335463-4488-1-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<4A3A4945.6050307@drmicha.warpmail.net>

This is a MONKEY PATCH which introduces a long option and config variable "branchse" analogous to "branches", with a short option "-B". It has the same meaning and can be used to accomadate svn repos with two different branches subdirectories.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 git-svn.perl |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

Well, this is not a serious patch per se, but it shows that git-svn can very well handle multiple branches configs once it is told to read and use them. I don't think it's possible to do this with globs, and extending globs to regexps looks like a more complicated approach (although they are used internally).

I see two viable options for a real patch now:
- Extend $remote->branches to be an array and use "config --get-all" to
  read the config; do the same for tags.
- Use one single array for branches as well as tags.

Eric, which way do you prefer? The first one is simpler and may be even doable for me. The second looks more complicated mainly because of "git svn branch -t" (which element of the combined array is tags?), even though it's more natural if one thinks about the way svn works.

Michael
diff --git a/git-svn.perl b/git-svn.perl
index 3301797..e6a9422 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -92,11 +92,12 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
 		'localtime' => \$Git::SVN::_localtime,
 		%remote_opts );
 
-my ($_trunk, $_tags, $_branches, $_stdlayout);
+my ($_trunk, $_tags, $_branches, $_branchse, $_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,
+                  'branchse|B=s' => \$_branchse,
                   'stdlayout|s' => \$_stdlayout,
                   'minimize-url|m' => \$Git::SVN::_minimize_url,
 		  'no-metadata' => sub { $icv{noMetadata} = 1 },
@@ -358,7 +359,7 @@ sub init_subdir {
 sub cmd_clone {
 	my ($url, $path) = @_;
 	if (!defined $path &&
-	    (defined $_trunk || defined $_branches || defined $_tags ||
+	    (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags ||
 	     defined $_stdlayout) &&
 	    $url !~ m#^[a-z\+]+://#) {
 		$path = $url;
@@ -375,7 +376,7 @@ sub cmd_init {
 		$_tags = 'tags' if (!defined $_tags);
 		$_branches = 'branches' if (!defined $_branches);
 	}
-	if (defined $_trunk || defined $_branches || defined $_tags) {
+	if (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags) {
 		return cmd_multi_init(@_);
 	}
 	my $url = shift or die "SVN repository location required ",
@@ -800,7 +801,7 @@ sub cmd_proplist {
 
 sub cmd_multi_init {
 	my $url = shift;
-	unless (defined $_trunk || defined $_branches || defined $_tags) {
+	unless (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags) {
 		usage(1);
 	}
 
@@ -825,9 +826,10 @@ sub cmd_multi_init {
 						   undef, $trunk_ref);
 		}
 	}
-	return unless defined $_branches || defined $_tags;
+	return unless defined $_branches || defined $_branchse || defined $_tags;
 	my $ra = $url ? Git::SVN::Ra->new($url) : undef;
 	complete_url_ls_init($ra, $_branches, '--branches/-b', $_prefix);
+	complete_url_ls_init($ra, $_branchse, '--branchse/-B', $_prefix);
 	complete_url_ls_init($ra, $_tags, '--tags/-t', $_prefix . 'tags/');
 }
 
@@ -1563,7 +1565,7 @@ sub fetch_all {
 	my $base = defined $fetch ? $head : 0;
 
 	# read the max revs for wildcard expansion (branches/*, tags/*)
-	foreach my $t (qw/branches tags/) {
+	foreach my $t (qw/branches branchse tags/) {
 		defined $remote->{$t} or next;
 		push @globs, $remote->{$t};
 		my $max_rev = eval { tmp_config(qw/--int --get/,
@@ -1609,7 +1611,7 @@ sub read_all_remotes {
 			$r->{$1}->{svm} = {};
 		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
 			$r->{$1}->{url} = $2;
-		} elsif (m!^(.+)\.(branches|tags)=
+		} elsif (m!^(.+)\.(branches|branchse|tags)=
 		           (.*):refs/remotes/(.+)\s*$/!x) {
 			my ($p, $g) = ($3, $4);
 			my $rs = $r->{$1}->{$2} = {
@@ -1760,7 +1762,7 @@ sub find_by_url { # repos_root and, path are optional
 		next if defined $repos_root && $repos_root ne $u;
 
 		my $fetch = $remotes->{$repo_id}->{fetch} || {};
-		foreach (qw/branches tags/) {
+		foreach (qw/branches branchse tags/) {
 			resolve_local_globs($u, $fetch,
 			                    $remotes->{$repo_id}->{$_});
 		}
-- 
1.6.3.2.406.gd6a466
Previous: Michael J GruberNext: Marc Branchaud
Message 9 of 23 in “git svn: Supporting multiple branch subdirs?”
  1. Marc BranchaudJun 12, 2009
  2. Michael J GruberJun 13, 2009
  3. Marc BranchaudJun 15, 2009
  4. Michael J GruberJun 17, 2009
  5. Marc BranchaudJun 17, 2009
  6. Michael J GruberJun 18, 2009
  7. Marc BranchaudJun 18, 2009
  8. Michael J GruberJun 18, 2009
  9. git-svn: allow two branch configurationsMichael J Gruber, Jun 18, 2009
  10. Marc BranchaudJun 22, 2009
  11. git svn: Support multiple branch and tag paths in the svn repository.Marc Branchaud, Jun 23, 2009
  12. Eric WongJun 25, 2009
  13. Junio C HamanoJun 25, 2009
  14. Eric WongJun 26, 2009
  15. Andreas EricssonJun 26, 2009
  16. Eric WongJun 26, 2009
  17. Marc BranchaudJun 26, 2009
  18. git svn: Doc update for multiple branch and tag pathsMarc Branchaud, Jun 26, 2009
  19. Eric WongJun 26, 2009
  20. git svn: Fix t9138-multiple-branches to use svn_cmd and (cd ...) syntax.Marc Branchaud, Jun 26, 2009
  21. Eric WongJun 26, 2009
  22. Marc BranchaudJun 27, 2009
  23. Eric WongJun 27, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.