Skip to content

Commit 73d4195

Browse files
Torsten SchmutzlerEric Wong
authored andcommitted
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 <[email protected]> Acked-by: Eric Wong <[email protected]>
1 parent 1174768 commit 73d4195

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

git-svn.perl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,14 @@ sub refname {
20872087
# .. becomes %2E%2E
20882088
$refname =~ s{\.\.}{%2E%2E}g;
20892089

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+
20902098
return $refname;
20912099
}
20922100

t/t9118-git-svn-funky-branch-names.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ test_expect_success 'setup svnrepo' '
2121
"$svnrepo/pr ject/branches/more fun plugin!" &&
2222
svn_cmd cp -m "scary" "$svnrepo/pr ject/branches/fun plugin" \
2323
"$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" &&
2432
start_httpd
2533
'
2634

@@ -30,6 +38,10 @@ test_expect_success 'test clone with funky branch names' '
3038
git rev-parse "refs/remotes/fun%20plugin" &&
3139
git rev-parse "refs/remotes/more%20fun%20plugin!" &&
3240
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" &&
3345
cd ..
3446
'
3547

@@ -51,6 +63,15 @@ test_expect_success 'test dcommit to scary branch' '
5163
cd ..
5264
'
5365

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+
5475
stop_httpd
5576

5677
test_done

0 commit comments

Comments
 (0)