@matheusbsbs / matheus-bagliano / commits / 73d419558d
Fork 0

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>

Torsten Schmutzler committed May 6, 2010 at 22:20 UTC 73d419558d9fa4de3be28bd58158636bc739808e
2 files changed +29
git-svn.perl
+8
@@ -2087,6 +2087,14 @@ sub refname {
2087 # .. becomes %2E%2E
2088 $refname =~ s{\.\.}{%2E%2E}g;
2089
2090 + # trailing dots and .lock are not allowed
2091 + # .$ becomes %2E and .lock becomes %2Elock
2092 + $refname =~ s{\.(?=$|lock$)}{%2E};
2093 +
2094 + # the sequence @{ is used to access the reflog
2095 + # @{ becomes %40{
2096 + $refname =~ s{\@\{}{%40\{}g;
2097 +
2098 return $refname;
2099 }
2100
t/t9118-git-svn-funky-branch-names.sh
+21
@@ -21,6 +21,14 @@ test_expect_success 'setup svnrepo' '
21 "$svnrepo/pr ject/branches/more fun plugin!" &&
22 svn_cmd cp -m "scary" "$svnrepo/pr ject/branches/fun plugin" \
23 "$svnrepo/pr ject/branches/$scary_uri" &&
24 + svn_cmd cp -m "leading dot" "$svnrepo/pr ject/trunk" \
25 + "$svnrepo/pr ject/branches/.leading_dot" &&
26 + svn_cmd cp -m "trailing dot" "$svnrepo/pr ject/trunk" \
27 + "$svnrepo/pr ject/branches/trailing_dot." &&
28 + svn_cmd cp -m "trailing .lock" "$svnrepo/pr ject/trunk" \
29 + "$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
30 + svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
31 + "$svnrepo/pr ject/branches/not-a@{0}reflog" &&
32 start_httpd
33 '
34
@@ -30,6 +38,10 @@ test_expect_success 'test clone with funky branch names' '
38 git rev-parse "refs/remotes/fun%20plugin" &&
39 git rev-parse "refs/remotes/more%20fun%20plugin!" &&
40 git rev-parse "refs/remotes/$scary_ref" &&
41 + git rev-parse "refs/remotes/%2Eleading_dot" &&
42 + git rev-parse "refs/remotes/trailing_dot%2E" &&
43 + git rev-parse "refs/remotes/trailing_dotlock%2Elock" &&
44 + git rev-parse "refs/remotes/not-a%40{0}reflog" &&
45 cd ..
46 '
47
@@ -51,6 +63,15 @@ test_expect_success 'test dcommit to scary branch' '
63 cd ..
64 '
65
66 +test_expect_success 'test dcommit to trailing_dotlock branch' '
67 + cd project &&
68 + git reset --hard "refs/remotes/trailing_dotlock%2Elock" &&
69 + echo who names branches like this anyway? >> foo &&
70 + git commit -m "bar" -- foo &&
71 + git svn dcommit &&
72 + cd ..
73 + '
74 +
75 stop_httpd
76
77 test_done