Skip to content

Compatibility with OSX #1

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions git-recent-branches
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ branch_limit = 10 if branch_limit == 0

show_current_branch = (`git config --get recent.showcurrent 2>/dev/null`.to_i == 1) ? true : false
current_branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.chomp
all_branches = `git reflog 2>/dev/null | \\grep -Pio "moving from ([^\\s]+)" | \\awk '{ print $3 }' | \\grep -Piv "[0-9a-f]{40}"`.split("\n")
all_branches = `git reflog 2>/dev/null | \\grep -Eio "moving from ([^\\s]+)$" | \\awk '{ print $3 }' | \\grep -Eiv "[0-9a-f]{40}"`.split("\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ([^\\s]+)$ here needs to change to ([^[:space:]]+) - at least that makes it work as it did before.


if all_branches.length == 0
puts "No recently viewed branches"
Expand Down Expand Up @@ -37,7 +37,7 @@ recent_branches.each do |branch_name|
last_commit_message = last_commit_message.lines.first.gsub("\n", "") unless last_commit_message == ""
longest_commit_message_length = last_commit_message.length unless last_commit_message.length <= longest_commit_message_length
longest_branch_name_length = branch_name.length unless branch_name.length <= longest_branch_name_length
recent_branch_list << { :number => number, :branch_name => branch_name, :commit_msg => last_commit_message }
recent_branch_list << { :number => number, :branch_name => branch_name.strip, :commit_msg => last_commit_message.strip }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch names shouldn't have a \r in them, I don't think, as the original regex matches anything but whitespace.

number += 1
end

Expand Down