Permalink
Browse files

Fix switching branches with no stash.

If you don't have any stashes, `.git/refs/stash` won't exist, so feeding
"refs/stash" into git-log gives an ugly error.  Since this was the last
thing that happened in feature-switch, it didn't cause any technical problems,
but it looked ugly.

Fixes #42.
  • Loading branch information...
1 parent 70fec6d commit f119f7cde43db22328a4f5199d27bcd0644d7739 @xiongchiamiov xiongchiamiov committed Feb 15, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 git.rb
View
@@ -127,6 +127,11 @@ def self.show_branch_list(options = {})
end
def self.stashes
+ # Do we even have a stash?
+ if ! File.exist? '.git/refs/stash'
+ return []
+ end
+
# format = "relative date|stash ref|commit message"
`git log --format="%ar|%gd|%s" -g "refs/stash"`.lines.map do |line|
fields = line.split '|', 3

0 comments on commit f119f7c

Please sign in to comment.