From 8efc64ad71fd89218820ff3097562b01399c1d65 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 25 Aug 2023 21:04:10 -0500 Subject: [PATCH] Change: (magit-todos-branch-list-merge-base-ref) Detect automatically Fixes #151. Closes #152. Reported-by: Aaron Zeng --- README.org | 1 + magit-todos.el | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 9007cd3e..ac3f28a9 100644 --- a/README.org +++ b/README.org @@ -133,6 +133,7 @@ Helm and Ivy are also supported. Note that the =helm= and =ivy= packages are no *Changed* + Improve behavior when scanner backend exits with an error. (Now an error is signaled and the command's output is shown.) ++ Option ~magit-todos-branch-list-merge-base-ref~ defaults to nil, which automatically detects the default branch name using function ~magit-main-branch~. ([[https://github.com/alphapapa/magit-todos/issues/151][#151]]. Thanks to [[https://github.com/bcc32][Aaron Zeng]] for reporting.) *Fixed* + Updated ~find|grep~ scanner for newer versions of GNU ~find~ that interpret some arguments differently. (Tested on v4.8.0.) diff --git a/magit-todos.el b/magit-todos.el index d48e3277..3b8518cb 100644 --- a/magit-todos.el +++ b/magit-todos.el @@ -370,7 +370,7 @@ This can be toggled locally in Magit buffers with command (const :tag "In non-master branches" branch) (const :tag "Always" t))) -(defcustom magit-todos-branch-list-merge-base-ref "master" +(defcustom magit-todos-branch-list-merge-base-ref nil "Commit ref passed to command \"git merge-base HEAD\". Determines the ancestor commit from which the current branch's todos should be searched for. May be overridden in the case that @@ -387,7 +387,8 @@ By default, the branch todo list would show todos from both the \"topic\" branch and the \"topic2\" branch. To show only todos from the \"topic2\" branch, this option could be set to \"topic\"." - :type 'string) + :type '(choice (const :tag "Automatic" :doc "Value returned by `magit-main-branch'" nil) + (string :tag "Specified branch name"))) (defcustom magit-todos-submodule-list nil "Show submodule to-do list." @@ -760,12 +761,14 @@ This function should be called from inside a ‘magit-status’ buffer." (magit-todos--insert-items (current-buffer) magit-todos-item-cache))) (when (or (eq magit-todos-branch-list t) (and (eq magit-todos-branch-list 'branch) - (not (string= "master" (magit-get-current-branch))))) + (not (equal (or magit-todos-branch-list-merge-base-ref (magit-main-branch)) + (magit-get-current-branch))))) ;; Insert branch-local items. (magit-todos--scan-with-git-diff :magit-status-buffer (current-buffer) :directory default-directory :depth magit-todos-depth - :heading (format "TODOs (branched from %s)" magit-todos-branch-list-merge-base-ref)))) + :heading (format "TODOs (branched from %s)" + (or magit-todos-branch-list-merge-base-ref (magit-main-branch)))))) (cl-defun magit-todos--insert-items (magit-status-buffer items &key branch-p) "Insert to-do ITEMS into MAGIT-STATUS-BUFFER.