git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote-hg: skip ill-formed references

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Aug 31, 2013, 17:32 UTC
Message-ID
<CAMP44s0Ht4tu3XuKW5BYFZFMHVMwMZtD8dJgULHqdb47__Hq5g@mail.gmail.com>
In-Reply-To
<loom.20130831T155657-714@post.gmane.org>
On Sat, Aug 31, 2013 at 8:58 AM, Max Kirillov <max@max630.net> wrote:
Show 8 quoted lines
> Felipe Contreras <felipe.contreras <at>
> gmail.com> writes:
>> Which repository triggered this?
>
> Tha was some of the vim repositories, upstream
> https://code.google.com/p/vim/ or debian
> anonscm.debian.org/hg/pkg-vim/vim, or both.
> They contain tags with ~ symbol.
Thanks.
> I don't have any experience with bazaar yet, so
> cannot say much about it.

That code is independent from bazaar. the ref_is_valid() method should return True or False depending on whether Git thinks it's a valid ref or not, it's independent from Bazaar or Mercurial, and all remote-helpers could share the same one.

So this is what I have in mind:
--- a/git-remote-hg.py
+++ b/git-remote-hg.py
@@ -617,6 +617,9 @@ def list_head(repo, cur):
     print "@refs/heads/%s HEAD" % head
     g_head = (head, node)

+def ref_is_valid(name):
+    return not True in [c in name for c in '~^: \\']
+
 def do_list(parser):
     repo = parser.repo
     for bmark, node in bookmarks.listbookmarks(repo).iteritems():
@@ -635,15 +638,24 @@ def do_list(parser):

     if track_branches:
         for branch in branches:
-            print "? refs/heads/branches/%s" % gitref(branch)
+            branch = gitref(branch)
+            if not ref_is_valid(branch):
+                continue
+            print "? refs/heads/branches/%s" % branch

     for bmark in bmarks:
-        print "? refs/heads/%s" % gitref(bmark)
+        bmark = gitref(bmark)
+        if not ref_is_valid(bmark):
+            continue
+        print "? refs/heads/%s" % bmark

     for tag, node in repo.tagslist():
         if tag == 'tip':
             continue
-        print "? refs/tags/%s" % gitref(tag)
+        tag = gitref(tag)
+        if not ref_is_valid(tag):
+            continue
+        print "? refs/tags/%s" % tag

     print
-- 
Felipe Contreras
Previous: Max KirillovNext: Felipe Contreras
Message 4 of 6 in “remote-hg: skip ill-formed references”
  1. remote-hg: skip ill-formed referencesMax Kirillov, Aug 31, 2013
  2. Felipe ContrerasAug 31, 2013
  3. Max KirillovAug 31, 2013
  4. Felipe ContrerasAug 31, 2013
  5. Felipe ContrerasAug 31, 2013
  6. Max KirillovAug 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.