summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Schmutzler <git-ts@theblacksun.eu>2010-05-06 22:20:43 +0200
committerEric Wong <normalperson@yhbt.net>2010-05-09 01:25:19 -0700
commit73d419558d9fa4de3be28bd58158636bc739808e (patch)
tree6ae114aeb4340195d457f6aa52978ceec3e1618a
parent1174768b460a5f24ef0323783ab69c578e5aa44a (diff)
downloadgit-73d419558d9fa4de3be28bd58158636bc739808e.tar.gz
git-svn: mangle refnames forbidden in git
git-check-ref-format(1) describes names which cannot be used as refnames for git. Some are legal branchnames in subversion however. Mangle the not yet handled cases. Signed-off-by: Torsten Schmutzler <git-ts@theblacksun.eu> Acked-by: Eric Wong <normalperson@yhbt.net>
-rwxr-xr-xgit-svn.perl8
-rwxr-xr-xt/t9118-git-svn-funky-branch-names.sh21
2 files changed, 29 insertions, 0 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 74d86128cc..b3b6964f95 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2087,6 +2087,14 @@ sub refname {
# .. becomes %2E%2E
$refname =~ s{\.\.}{%2E%2E}g;
+ # trailing dots and .lock are not allowed
+ # .$ becomes %2E and .lock becomes %2Elock
+ $refname =~ s{\.(?=$|lock$)}{%2E};
+
+ # the sequence @{ is used to access the reflog
+ # @{ becomes %40{
+ $refname =~ s{\@\{}{%40\{}g;
+
return $refname;
}
diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index ac52bff0ef..7d7acc30b4 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -21,6 +21,14 @@ test_expect_success 'setup svnrepo' '
"$svnrepo/pr ject/branches/more fun plugin!" &&
svn_cmd cp -m "scary" "$svnrepo/pr ject/branches/fun plugin" \
"$svnrepo/pr ject/branches/$scary_uri" &&
+ svn_cmd cp -m "leading dot" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/.leading_dot" &&
+ svn_cmd cp -m "trailing dot" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/trailing_dot." &&
+ svn_cmd cp -m "trailing .lock" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
+ svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/not-a@{0}reflog" &&
start_httpd
'
@@ -30,6 +38,10 @@ test_expect_success 'test clone with funky branch names' '
git rev-parse "refs/remotes/fun%20plugin" &&
git rev-parse "refs/remotes/more%20fun%20plugin!" &&
git rev-parse "refs/remotes/$scary_ref" &&
+ git rev-parse "refs/remotes/%2Eleading_dot" &&
+ git rev-parse "refs/remotes/trailing_dot%2E" &&
+ git rev-parse "refs/remotes/trailing_dotlock%2Elock" &&
+ git rev-parse "refs/remotes/not-a%40{0}reflog" &&
cd ..
'
@@ -51,6 +63,15 @@ test_expect_success 'test dcommit to scary branch' '
cd ..
'
+test_expect_success 'test dcommit to trailing_dotlock branch' '
+ cd project &&
+ git reset --hard "refs/remotes/trailing_dotlock%2Elock" &&
+ echo who names branches like this anyway? >> foo &&
+ git commit -m "bar" -- foo &&
+ git svn dcommit &&
+ cd ..
+ '
+
stop_httpd
test_done