Skip to content

Commit 4c00819

Browse files
felipecgitster
authored andcommitted
remote-bzr: avoid bad refs
Versions of fast-export before v1.8.2 throws a bad 'reset' commands because of a behavior in transport-helper that is not even needed. We should ignore them, otherwise we will treat 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0818112 commit 4c00819

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -682,23 +682,31 @@ def do_export(parser):
682682
die('unhandled export command: %s' % line)
683683

684684
for ref, revid in parsed_refs.iteritems():
685-
name = ref[len('refs/heads/'):]
686-
branch = bzrlib.branch.Branch.open(branches[name])
687-
branch.generate_revision_history(revid, marks.get_tip(name))
685+
if ref.startswith('refs/heads/'):
686+
name = ref[len('refs/heads/'):]
687+
branch = bzrlib.branch.Branch.open(branches[name])
688+
branch.generate_revision_history(revid, marks.get_tip(name))
688689

689-
if name in peers:
690-
peer = bzrlib.branch.Branch.open(peers[name])
691-
try:
692-
peer.bzrdir.push_branch(branch, revision_id=revid)
693-
except bzrlib.errors.DivergedBranches:
694-
print "error %s non-fast forward" % ref
695-
continue
690+
if name in peers:
691+
peer = bzrlib.branch.Branch.open(peers[name])
692+
try:
693+
peer.bzrdir.push_branch(branch, revision_id=revid)
694+
except bzrlib.errors.DivergedBranches:
695+
print "error %s non-fast forward" % ref
696+
continue
696697

697-
try:
698-
wt = branch.bzrdir.open_workingtree()
699-
wt.update()
700-
except bzrlib.errors.NoWorkingTree:
701-
pass
698+
try:
699+
wt = branch.bzrdir.open_workingtree()
700+
wt.update()
701+
except bzrlib.errors.NoWorkingTree:
702+
pass
703+
elif ref.startswith('refs/tags/'):
704+
# TODO: implement tag push
705+
print "error %s pushing tags not supported" % ref
706+
continue
707+
else:
708+
# transport-helper/fast-export bugs
709+
continue
702710

703711
print "ok %s" % ref
704712

0 commit comments

Comments
 (0)