branch: externals/agitate commit 27cdb6fd95ad88a10308214148dd805de6a64a76 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Improve agitate-vc-git-prompt-format-patch-single --- README.org | 5 ++++- agitate.el | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 16d3aa2e91..2daa6ebf16 100644 --- a/README.org +++ b/README.org @@ -155,7 +155,10 @@ think most of those are superfluous. Less is more. #+findex: agitate-vc-git-prompt-format-patch-single + ~agitate-vc-git-prompt-format-patch-single~ :: Format patch for a - single =COMMIT=. Prompt for =COMMIT= using minibuffer completion. + single =COMMIT=. If in a log-view buffer, the =COMMIT= is the one + at point. For the details of how that is determined, read the doc + string of ~agitate-log-view-kill-revision~. If there is no such + commit at point, prompt for =COMMIT= using minibuffer completion. Output the patch file to the return value of the function ~vc-root-dir~. Relevant except from the source code: diff --git a/agitate.el b/agitate.el index ca34d3170c..cddd7eb662 100644 --- a/agitate.el +++ b/agitate.el @@ -277,15 +277,27 @@ to those pertaining to the current file." (with-current-buffer (pop-to-buffer buf) (diff-mode)))) +(defun agitate--vc-git-format-patch-single-behaviour () + "Help `agitate-vc-git-prompt-format-patch-single' with its COMMIT." + (if-let ((default-value (cadr (log-view-current-entry (point) t)))) + default-value + (agitate--vc-git-get-hash-from-string (agitate--vc-git-commit-prompt)))) + ;;;###autoload (defun agitate-vc-git-prompt-format-patch-single (commit) "Format patch for a single COMMIT. -Prompt for COMMIT using minibuffer completion. + +If in a log-view buffer, the COMMIT is the one at point. For the +details of how that is determined, read the doc string of +`agitate-log-view-kill-revision'. + +If there is no such commit at point, prompt for COMMIT using +minibuffer completion. Output the patch file to the return value of the function `vc-root-dir'." (interactive - (list (agitate--vc-git-get-hash-from-string (agitate--vc-git-commit-prompt)))) + (list (agitate--vc-git-format-patch-single-behaviour))) ;; TODO 2022-09-27: Handle the output directory better. Though I am ;; not sure how people work with those. I normally use the root of ;; the current repo (and then clean it) or put everything in the