Skip to content

Commit d750c3e

Browse files
committed
Fixed git-wtf so it doesn't show orphaned branches
1 parent 47a743a commit d750c3e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

git-wtf

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,18 @@ def show b, all_branches
9696
if $config["versions"].include? b[:remote_branch]
9797
puts "\nFeature branches:" unless fbs.empty?
9898
fbs.each do |name, br|
99-
remote_ahead = commits_between b[:remote_branch], br[:local_branch]
100-
local_ahead = commits_between b[:local_branch], br[:local_branch]
101-
if local_ahead.empty? && remote_ahead.empty?
102-
puts "[x] #{br[:name]} is merged in"
103-
elsif local_ahead.empty?
104-
puts "(x) #{br[:name]} merged in (only locally)"
105-
else
106-
behind = commits_between br[:local_branch], b[:remote_branch]
107-
puts "[ ] #{br[:name]} is NOT merged in (#{ahead_behind_string local_ahead, behind})"
108-
show_commits local_ahead, nil, " "
99+
if not `git merge-base #{b[:remote_branch]} #{br[:local_branch]}`.split("\n").empty?
100+
remote_ahead = commits_between b[:remote_branch], br[:local_branch]
101+
local_ahead = commits_between b[:local_branch], br[:local_branch]
102+
if local_ahead.empty? && remote_ahead.empty?
103+
puts "[x] #{br[:name]} is merged in"
104+
elsif local_ahead.empty?
105+
puts "(x) #{br[:name]} merged in (only locally)"
106+
else
107+
behind = commits_between br[:local_branch], b[:remote_branch]
108+
puts "[ ] #{br[:name]} is NOT merged in (#{ahead_behind_string local_ahead, behind})"
109+
show_commits local_ahead, nil, " "
110+
end
109111
end
110112
end
111113
else

0 commit comments

Comments
 (0)