[PATCH 1/2] Fix multi-glob assertion in git-svn

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] Fix multi-glob assertion in git-svn

Marcus Griep
From 81b736f4a815ebded8978e63f2cba393528a57e0 Mon Sep 17 00:00:00 2001
From: Marcus Griep <[hidden email]>
Date: Tue, 5 Aug 2008 15:45:05 -0400
Subject: [PATCH 1/2] Fix multi-glob assertion in git-svn

Signed-off-by: Marcus Griep <[hidden email]>
---
 git-svn.perl            |    5 +++--
 t/t9108-git-svn-glob.sh |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index cf6dbbc..95d11c2 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4904,14 +4904,15 @@ sub new {
        my ($class, $glob) = @_;
        my $re = $glob;
        $re =~ s!/+$!!g; # no need for trailing slashes
-       my $nr = ($re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g);
-       my ($left, $right) = ($1, $2);
+       my $nr = $re =~ tr/*/*/;
        if ($nr > 1) {
                die "Only one '*' wildcard expansion ",
                    "is supported (got $nr): '$glob'\n";
        } elsif ($nr == 0) {
                die "One '*' is needed for glob: '$glob'\n";
        }
+       $re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
+       my ($left, $right) = ($1, $2);
        $re = quotemeta($left) . $re . quotemeta($right);
        if (length $left && !($left =~ s!/+$!!g)) {
                die "Missing trailing '/' on left side of: '$glob' ($left)\n";
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index f6f71d0..ef6d88e 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -83,4 +83,23 @@ test_expect_success 'test left-hand-side only globbing' '
        cmp expect.two output.two
        '

+echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multi-globs' '
+       git config --add svn-remote.three.url "$svnrepo" &&
+       git config --add svn-remote.three.fetch trunk:refs/remotes/three/trunk &&
+       git config --add svn-remote.three.branches \
+                        "branches/*/*:refs/remotes/three/branches/*" &&
+       git config --add svn-remote.three.tags \
+                        "tags/*/*:refs/remotes/three/tags/*" &&
+       cd tmp &&
+               echo "try try" >> tags/end/src/b/readme &&
+               poke tags/end/src/b/readme &&
+               svn commit -m "try to try"
+               cd .. &&
+       test_must_fail git-svn fetch three &> stderr.three &&
+       cmp expect.three stderr.three
+       '
+
 test_done
--
1.5.4.3

--
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html