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

Re: [RFC PATCH] git-svn does not support intermediate directories?

From
MLMichael Lai <myllai@gmail.com>
Date
Mar 9, 2009, 21:02 UTC
Message-ID
<21fc26450903091402u60d6cfcepd67ba7510af8f4a3@mail.gmail.com>
In-Reply-To
<20090308044318.GA31205@untitled>
> Your patch was whitespace damaged and lacked a proposed commit message.
> Please read Documentation/SubmittingPatches next time.
Hey Eric,

Sorry, I didn't notice that; I've read through it and hopefully my patches should conform from now on.

>
> Anyhow, I fixed your patch up a bit.  Can you sign-off on it
> if its right to you or let me know if it's broken?  Thanks.

I looked through the patch and that would work, but at the same time I had another idea which may be a little cleaner. Let me know what you think.

From ae38acf85cfc86c075578c1c3f3c204d91d1d1f4 Mon Sep 17 00:00:00 2001
From: Michael Lai <myllai@gmail.com>
Date: Mon, 9 Mar 2009 11:45:47 -0700
Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches
For repositories laid out like the following:
[svn-remote "svn"]
      url = http://foo.com/svn/repos/bar
      fetch = myproject/trunk:refs/remotes/trunk
      branches = bar/myproject/branches/*:refs/remotes/*
      tags = bar/myproject/tags/*:refs/remotes/tags/*

The "bar" component above is considered the intermediate path and was not handled correctly.

Signed-off-by: Michael Lai <myllai@gmail.com>
---
 git-svn.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 959eb52..8be6be0 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2351,7 +2351,10 @@ sub match_paths {
 	if (my $path = $paths->{"/$self->{path}"}) {
 		return ($path->{action} eq 'D') ? 0 : 1;
 	}
-	$self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
+	my $repos_root = $self->ra->{repos_root};
+	my $extended_path = $self->{url} . '/' . $self->{path};
+	$extended_path =~ s#^\Q$repos_root\E(/|$)##;
+	$self->{path_regex} ||= qr/^\/\Q$extended_path\E\//;
 	if (grep /$self->{path_regex}/, keys %$paths) {
 		return 1;
 	}
-- 
1.6.2

>
> From cddc7e5bde060eb963534156ae0daaf41c87c21a Mon Sep 17 00:00:00 2001
> From: Eric Wong <normalperson@yhbt.net>
> Date: Sat, 7 Mar 2009 20:22:29 -0800
> Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches
> MIME-Version: 1.0
> Content-Type: text/plain; charset=utf-8
> Content-Transfer-Encoding: 8bit
>
> For repositories laid out like the following:
>
>> [svn-remote "svn"]
>>       url = http://foo.com/svn/repos/bar
>>       fetch = myproject/trunk:refs/remotes/trunk
>>       branches = bar/myproject/branches/*:refs/remotes/*
>>       tags = bar/myproject/tags/*:refs/remotes/tags/*
>
> The "bar" component above is considered the intermediate path
> and was not handled correctly.
>
> This patch was originally by Michael Lai (without a commit
> message) with some minor fixes:
>
>  * extraneous slash removed from $intermediate_path,
>    this was causing tests to fail.
>
>  * fixed a case where $intermediate_path could be "0" and
>    considered false by Perl, preventing the necessary
>    slash from being appended.
>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> ---
>  git-svn.perl |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 959eb52..745dd03 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2351,7 +2351,11 @@ sub match_paths {
>        if (my $path = $paths->{"/$self->{path}"}) {
>                return ($path->{action} eq 'D') ? 0 : 1;
>        }
> -       $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
> +       my $repos_root = $self->ra->{repos_root};
> +       my $intermediate_path = $self->{url};
> +       $intermediate_path =~ s#^\Q$repos_root\E(/|$)##;
> +       $intermediate_path .= '/' if length($intermediate_path) > 0;
> +       $self->{path_regex} ||= qr/^\/\Q$intermediate_path$self->{path}\E\//;
>        if (grep /$self->{path_regex}/, keys %$paths) {
>                return 1;
>        }
> --
> Eric Wong
>
Previous: Eric WongNext: Eric Wong
Message 5 of 6 in “git-svn does not support intermediate directories?”
  1. Michael LaiMar 4, 2009
  2. Tim StoakesMar 4, 2009
  3. Michael LaiMar 6, 2009
  4. Eric WongMar 8, 2009
  5. Michael LaiMar 9, 2009
  6. Eric WongMar 9, 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.