Skip to content

Commit

Permalink
Work around git ignoring the remote-helper exit code on import
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Sep 25, 2021
1 parent 8f82357 commit 42ee216
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions cinnabar/remote_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,24 @@ def run(self):
args = args[0].split(b' ', 1)

if cmd == b'import':
# Can't have a method named import
cmd = b'import_'
func = getattr(self, cmd.decode('ascii'), None)
assert func
func(*args)
# Can't have a method named import, so we use import_
try:
self.import_(*args)
except Exception:
# The Exception will eventually get us to return an error
# code, but git actually ignores it. So we send it a
# command it doesn't know over the helper/fast-import
# protocol, so that it emits an error.
# Alternatively, we could send `feature done` before doing
# anything, and on the `done` command not being sent when
# an exception is thrown, triggering an error, but that
# requires git >= 1.7.7.
self._helper.write(b'error\n')
raise
else:
func = getattr(self, cmd.decode('ascii'), None)
assert func
func(*args)

def option(self, name, value):
if name == b'progress' and value in (b'true', b'false'):
Expand Down

0 comments on commit 42ee216

Please sign in to comment.