Skip to content

Commit

Permalink
Fix switching branches with no stash.
Browse files Browse the repository at this point in the history
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
xiongchiamiov committed Feb 15, 2013
1 parent 70fec6d commit f119f7c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions git.rb
Expand Up @@ -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
Expand Down

0 comments on commit f119f7c

Please sign in to comment.