From: Max Kirillov <max@max630.net>
To: Felipe Contreras <felipe.contreras@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] remote-hg: skip ill-formed references
Date: Sat, 31 Aug 2013 04:15:42 +0300 [thread overview]
Message-ID: <20130831011542.GA10486@wheezy.local> (raw)
References which fail check_refname_format() cause the whole
import to fail. This might be undesirable if the references
are not important.
A better solution would be to provide some mapping, either
by some reversible encoding, or by generating and storing
the associations locally.
But this is already going to allow working with many
existing repositories.
---
If there is no smarter solution ongoing maybe this could be
useful.
contrib/remote-helpers/git-remote-hg | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 0194c67..e32003b 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -591,6 +591,17 @@ def list_head(repo, cur):
print "@refs/heads/%s HEAD" % head
g_head = (head, node)
+def print_list_entry_if_valid(ref):
+ # same checks as in check_refname_format() in refs.c
+ if ref.startswith('.') or ref.find('/.') != -1 or \
+ ref.find('..') != -1 or \
+ any([(c <= ' ' or c in '~^:\\\177') for c in ref]) or \
+ ref.endswith('/') or \
+ ref.endswith('.lock'):
+ warn("Ill-named reference '%s' skipped" % ref)
+ else:
+ print "? %s" % ref
+
def do_list(parser):
global branches, bmarks, track_branches
@@ -611,15 +622,15 @@ def do_list(parser):
if track_branches:
for branch in branches:
- print "? refs/heads/branches/%s" % gitref(branch)
+ print_list_entry_if_valid("refs/heads/branches/%s" % gitref(branch))
for bmark in bmarks:
- print "? refs/heads/%s" % gitref(bmark)
+ print_list_entry_if_valid("refs/heads/%s" % gitref(bmark))
for tag, node in repo.tagslist():
if tag == 'tip':
continue
- print "? refs/tags/%s" % gitref(tag)
+ print_list_entry_if_valid("refs/tags/%s" % gitref(tag))
print
--
1.8.4.rc3.902.g80a4b9e
next reply other threads:[~2013-08-31 1:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-31 1:15 Max Kirillov [this message]
2013-08-31 1:39 ` [PATCH] remote-hg: skip ill-formed references Felipe Contreras
2013-08-31 13:58 ` Max Kirillov
2013-08-31 17:32 ` Felipe Contreras
2013-08-31 17:57 ` Felipe Contreras
2013-08-31 19:51 ` Max Kirillov
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=20130831011542.GA10486@wheezy.local \
--to=max@max630.net \
--cc=felipe.contreras@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).