summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Lucarella <leandro.lucarella@sociomantic.com>2014-06-13 16:31:54 +0200
committerMihails Strasuns <mihails.strasuns@sociomantic.com>2014-06-13 17:08:14 +0200
commitd2f0ab7a38ddaeaa18dc0d8f391acef45311e997 (patch)
tree93d4a3a77b6b30a4b1e12ec88596cc93a6759692
parentaf65498bc46d15f25e3ce426c7bcb41dc3e4d9a6 (diff)
Fix handling of stashed changes that are not last in the stack
The code handling the case where the stashed changes produced by git-hub were not last in the stash was completely broken after a refactoring done in 84fcb10bce6b3b617fce6922c640b2b699aadda5. This should finally fix #91.
-rwxr-xr-xgit-hub20
1 files changed, 9 insertions, 11 deletions
diff --git a/git-hub b/git-hub
index a1c99b6..1a1f78f 100755
--- a/git-hub
+++ b/git-hub
@@ -1581,29 +1581,27 @@ class RebaseCmd (PullUtil):
# Returns True if it was successfully popped, False otherwise.
@classmethod
def pop_stashed(cls):
- stashed_state = cls.get_stashed_state()
- if stashed_state:
+ stashed_index = cls.get_stashed_state()
+ if stashed_index == 0:
git_quiet(2, 'stash', 'pop')
return True
- elif stashed_state is False:
+ elif stashed_index > 0:
warnf("Stash produced by this command found "
"(stash@{{}}) but not as the last stashed "
- "changes, leaving the stashed as it is", i)
+ "changes, leaving the stashed as it is",
+ stashed_index)
return False
- # Returns True if the stash created by this program is the latest stash
- # in the stack, False if is present but is not on the top of the stack,
- # and None if is not present at all.
+ # Returns the index of the stash created by this program in the stash
+ # in the stack, or None if not present at all. 0 means is the latest
+ # stash in the stash stack.
@classmethod
def get_stashed_state(cls):
stash_msg_re = re.compile(r'.*' + cls.stash_msg_base + r' \d+')
stashs = git('stash', 'list').splitlines()
for i, stash in enumerate(stashs):
if stash_msg_re.match(stash):
- if i == 0:
- return True
- else:
- return False
+ return i
return None
# Returns a string with the message to use when stashing local changes.