Skip to content

Commit 93baaac

Browse files
committedJan 22, 2017
GitRepository.restore_head(): new method
1 parent e0d5436 commit 93baaac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎git-imerge

+6-6
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,15 @@ class GitTemporaryHead(object):
310310
"""
311311

312312
def __enter__(self, git, message):
313+
self.git = git
313314
self.message = message
314315
self.head_name = git.get_head_refname()
315316
return self
316317

317318
def __exit__(self, exc_type, exc_val, exc_tb):
318319
if self.head_name:
319320
try:
320-
check_call([
321-
'git', 'symbolic-ref',
322-
'-m', self.message, 'HEAD',
323-
self.head_name,
324-
])
325-
check_call(['git', 'reset', '--hard'])
321+
self.git.restore_head(self.head_name, self.message)
326322
except CalledProcessError as e:
327323
raise Failure(
328324
'Could not restore HEAD to %r!: %s\n'
@@ -989,6 +985,10 @@ class GitRepository(object):
989985
except CalledProcessError:
990986
return None
991987

988+
def restore_head(self, refname, message):
989+
check_call(['git', 'symbolic-ref', '-m', message, 'HEAD', refname])
990+
check_call(['git', 'reset', '--hard'])
991+
992992
def checkout(self, refname, quiet=False):
993993
cmd = ['git', 'checkout']
994994
if quiet:

0 commit comments

Comments
 (0)
Please sign in to comment.