summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
450ae43)
Resetting HEAD on the current branch when popping a patch on another
branch isn't a great idea.
Signed-off-by: Karl Hasselström <kha@treskal.com>
[os.path.join('refs', 'heads', ref)]) != 0:
raise GitException, 'Could not set head to "%s"' % ref
[os.path.join('refs', 'heads', ref)]) != 0:
raise GitException, 'Could not set head to "%s"' % ref
+def set_branch(branch, val):
+ """Point branch at a new commit object."""
+ if __run('git-update-ref', [branch, val]) != 0:
+ raise GitException, 'Could not update %s to "%s".' % (branch, val)
+
def __set_head(val):
"""Sets the HEAD value
"""
global __head
if not __head or __head != val:
def __set_head(val):
"""Sets the HEAD value
"""
global __head
if not __head or __head != val:
- if __run('git-update-ref HEAD', [val]) != 0:
- raise GitException, 'Could not update HEAD to "%s".' % val
+ set_branch('HEAD', val)
__head = val
# only allow SHA1 hashes
__head = val
# only allow SHA1 hashes
patch = Patch(name, self.__patch_dir, self.__refs_dir)
patch = Patch(name, self.__patch_dir, self.__refs_dir)
- # only keep the local changes
- if keep and not git.apply_diff(git.get_head(), patch.get_bottom()):
- raise StackException, \
- 'Failed to pop patches while preserving the local changes'
-
- git.switch(patch.get_bottom(), keep)
+ if git.get_head_file() == self.get_branch():
+ if keep and not git.apply_diff(git.get_head(), patch.get_bottom()):
+ raise StackException(
+ 'Failed to pop patches while preserving the local changes')
+ git.switch(patch.get_bottom(), keep)
+ else:
+ git.set_branch(self.get_branch(), patch.get_bottom())
# save the new applied list
idx = applied.index(name) + 1
# save the new applied list
idx = applied.index(name) + 1