From 5c7b6b2efee4c1e5329a2a74962f034f15e653a6 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 8 Mar 2009 14:41:52 +0200 Subject: [PATCH] Make 'i' toggle the ignore flag for wazzup. * magit.el (magit-write-file-lines): New. (magit-wazzup-toggle-ignore): New, use it instead of magit-wazzup-ignore. * magit.texi: Document it. --- magit.el | 22 ++++++++++++++++++---- magit.texi | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/magit.el b/magit.el index e8e53343..477218f0 100644 --- a/magit.el +++ b/magit.el @@ -42,6 +42,7 @@ ;; ;; Later: ;; +;; - Queuing of asynchronous commands. ;; - Good email integration. ;; - Showing tags. ;; - Visiting from staged hunks doesn't always work since the line @@ -266,6 +267,12 @@ Many Magit faces inherit from this one by default." (cdr rev) rev)))))) +(defun magit-write-file-lines (file lines) + (with-temp-buffer + (dolist (l lines) + (insert l "\n")) + (write-file file))) + (defun magit-concat-with-delim (delim seqs) (cond ((null seqs) nil) @@ -2682,12 +2689,19 @@ Prefix arg means justify as well." ;;; Wazzup -(defun magit-wazzup-ignore (branch edit) +(defun magit-wazzup-toggle-ignore (branch edit) (let ((ignore-file ".git/info/wazzup-exclude")) (if edit (setq branch (read-string "Branch to ignore for wazzup: " branch))) - (append-to-file (concat branch "\n") nil ignore-file) - (magit-need-refresh))) + (let ((ignored (magit-file-lines ignore-file))) + (cond ((member branch ignored) + (when (or (not edit) + (y-or-n-p "Branch %s is already ignored. Unignore?")) + (setq ignored (delete branch ignored)))) + (t + (setq ignored (append ignored (list branch))))) + (magit-write-file-lines ignore-file ignored) + (magit-need-refresh)))) (defun magit-refresh-wazzup-buffer (head all) (magit-create-buffer-sections @@ -2749,7 +2763,7 @@ Prefix arg means justify as well." ((untracked file) (magit-ignore-file info current-prefix-arg nil)) ((wazzup) - (magit-wazzup-ignore info current-prefix-arg)))) + (magit-wazzup-toggle-ignore info current-prefix-arg)))) (defun magit-ignore-item-locally () (interactive) diff --git a/magit.texi b/magit.texi index d3fbd1aa..fe2a0907 100644 --- a/magit.texi +++ b/magit.texi @@ -447,7 +447,8 @@ corresponding branch will be offered as the default for a merge. Hitting @kbd{i} on a branch title will ignore this branch in the wazzup view. You can use @kbd{C-u w} to show all branches, including -the ignored ones. +the ignored ones. Hitting @kbd{i} on an already ignored branch in +that view will unignore it. @node Merging @chapter Merging