All of lore.kernel.org
 help / color / mirror / Atom feed
From: Torsten Schmutzler <git-ts@theblacksun.eu>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] git-svn: mangle refnames forbidden in git
Date: Thu, 06 May 2010 22:20:43 +0200	[thread overview]
Message-ID: <4BE3249B.7050100@theblacksun.eu> (raw)

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>
---
 git-svn.perl                          |    8 ++++++++
 t/t9118-git-svn-funky-branch-names.sh |   21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 2c86ea2..57df509 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2086,6 +2086,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 ac52bff..7d7acc3 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
-- 
1.7.1.12.ge45de

             reply	other threads:[~2010-05-06 20:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06 20:20 Torsten Schmutzler [this message]
2010-05-09  8:35 ` [PATCH] git-svn: mangle refnames forbidden in git Eric Wong
2010-07-08  8:43 ` Jonathan Nieder
2010-07-08  8:58   ` Eric Wong
2010-07-08 13:03     ` Jonathan Nieder
2010-07-08 18:53       ` Michael J Gruber
2010-07-08 19:16         ` [PATCH] t9118: avoid PEG revision identifier in tests Michael J Gruber
2010-07-08 19:33           ` A Large Angry SCM
2010-07-08 20:38           ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE3249B.7050100@theblacksun.eu \
    --to=git-ts@theblacksun.eu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.