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

[PATCH v2 2/2] remote-bzr: avoid bad refs

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 4, 2013, 00:31 UTC
Message-ID
<1367627467-15132-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1367627467-15132-1-git-send-email-felipe.contreras@gmail.com>

Turns out fast-export throws bad 'reset' commands because of a behavior in transport-helper that is not even needed.

We should ignore them, otherwise we will threat them as branches and fail.

This was fixed in v1.8.2, but some people use this script in older versions of git.

Also, check if the ref was a tag, and skip it for now.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 38 +++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index bbaaa8f..0ef30f8 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -682,23 +682,31 @@ def do_export(parser):
             die('unhandled export command: %s' % line)
 
     for ref, revid in parsed_refs.iteritems():
-        name = ref[len('refs/heads/'):]
-        branch = bzrlib.branch.Branch.open(branches[name])
-        branch.generate_revision_history(revid, marks.get_tip(name))
+        if ref.startswith('refs/heads/'):
+            name = ref[len('refs/heads/'):]
+            branch = bzrlib.branch.Branch.open(branches[name])
+            branch.generate_revision_history(revid, marks.get_tip(name))
 
-        if name in peers:
-            peer = bzrlib.branch.Branch.open(peers[name])
-            try:
-                peer.bzrdir.push_branch(branch, revision_id=revid)
-            except bzrlib.errors.DivergedBranches:
-                print "error %s non-fast forward" % ref
-                continue
+            if name in peers:
+                peer = bzrlib.branch.Branch.open(peers[name])
+                try:
+                    peer.bzrdir.push_branch(branch, revision_id=revid)
+                except bzrlib.errors.DivergedBranches:
+                    print "error %s non-fast forward" % ref
+                    continue
 
-        try:
-            wt = branch.bzrdir.open_workingtree()
-            wt.update()
-        except bzrlib.errors.NoWorkingTree:
-            pass
+            try:
+                wt = branch.bzrdir.open_workingtree()
+                wt.update()
+            except bzrlib.errors.NoWorkingTree:
+                pass
+        elif ref.startswith('refs/tags/'):
+            # TODO: implement tag push
+            print "error %s pushing tags not supported" % ref
+            continue
+        else:
+            # transport-helper/fast-export bugs
+            continue
 
         print "ok %s" % ref
 
-- 
1.8.3.rc0.401.g45bba44
Previous: Felipe ContrerasNext: Stefano Lattarini
Message 3 of 10 in “remote-bzr: couple of fixes”
  1. 0/2 remote-bzr: couple of fixesFelipe Contreras, May 4, 2013
  2. 1/2 remote-bzr: convert all unicode keys to strFelipe Contreras, May 4, 2013
  3. 2/2 remote-bzr: avoid bad refsFelipe Contreras, May 4, 2013
  4. Stefano LattariniMay 4, 2013
  5. Junio C HamanoMay 5, 2013
  6. Felipe ContrerasMay 5, 2013
  7. Junio C HamanoMay 5, 2013
  8. Felipe ContrerasMay 5, 2013
  9. Junio C HamanoMay 5, 2013
  10. Felipe ContrerasMay 5, 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.