From b991100ce6f761e30fd256871abdd00e02031c94 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 18 Feb 2009 01:28:57 -0400 Subject: [PATCH] Several improvements to the whazzup command 1. Don't report a branch if it has no commit in common with HEAD. This is for people who keep alternate histories in their repositories. 2. Don't report a branch if another branch with the same basename and commit as HEAD has already been reported. Thus, if a branch "foo" with 5 unpulled commits was pushed to origin, don't display both "foo" and "origin/foo" in the whazzup buffer, since they reflect the same thing. --- magit.el | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/magit.el b/magit.el index 1f03ae4e..c5070c66 100644 --- a/magit.el +++ b/magit.el @@ -2584,23 +2584,31 @@ Prefix arg means justify as well." (magit-create-buffer-sections (magit-with-section 'wazzupbuf nil (insert (format "Wazzup, %s\n\n" head)) - (let ((branches (magit-git-lines "branch -a | cut -c3-"))) + (let ((branches (magit-git-lines "branch -a | cut -c3-")) + (reported (make-hash-table :test #'equal))) (dolist (b branches) - (let* ((n (magit-git-string "log --pretty=oneline %s..%s | wc -l" - head b)) - (section - (let ((magit-section-hidden-default t)) - (magit-git-section - (cons b 'wazzup) - (format "%s unmerged commits in %s" - n b) - 'magit-wash-log - "log" - (format "--max-count=%s" magit-log-cutoff-length) - "--pretty=oneline" - (format "%s..%s" head b) - "--")))) - (magit-set-section-info b section))))))) + (let* ((hash (magit-git-string "rev-parse %s" b)) + (reported-branch (gethash hash reported))) + (unless (or (and reported-branch + (string= (file-name-nondirectory b) + reported-branch)) + (not (magit-git-string "merge-base %s %s" head b))) + (puthash hash (file-name-nondirectory b) reported) + (let* ((n (magit-git-string "log --pretty=oneline %s..%s | wc -l" + head b)) + (section + (let ((magit-section-hidden-default t)) + (magit-git-section + (cons b 'wazzup) + (format "%s unmerged commits in %s" + n b) + 'magit-wash-log + "log" + (format "--max-count=%s" magit-log-cutoff-length) + "--pretty=oneline" + (format "%s..%s" head b) + "--")))) + (magit-set-section-info b section))))))))) (defun magit-wazzup () (interactive)