aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoctocell <public@yoctocell.xyz>2021-01-18 15:09:36 +0100
committeryoctocell <public@yoctocell.xyz>2021-01-18 15:09:36 +0100
commit26745cb6454cfe8ab5d94359963383e016dfe2c5 (patch)
tree452997d72d2e9897e159c735becc2ad3a3d0fec3
parentc5b82e14cacaf2757e1e0de9d5a92e3fa4234e1b (diff)
Rework `git-email-format-patch'
These changes were made to make git-email work better with Magit (the following commit will cover this). ARGS is a string of arguments passed to "git format-patch", RANGE is the range of commits to create patches from. If prefix argument KEEP is specified, keep the generated patches, be default they will be deleted like with "git send-email".
-rw-r--r--git-email.el62
1 files changed, 30 insertions, 32 deletions
diff --git a/git-email.el b/git-email.el
index ad08548..f16798e 100644
--- a/git-email.el
+++ b/git-email.el
@@ -293,44 +293,42 @@ them into the message buffer."
(cadr (log-view-current-entry (point) t))))
;;;###autoload
-(defun git-email-format-patch (&optional args keep)
+(defun git-email-format-patch (args range keep)
"Format and send patch(es) using 'git format-patch'.
-With optional ARGS (\\[universal-argument]) you can specify extra
-arguments to give to 'git format-patch'. By default, the
-arguments in `git-email-format-patch-default-args' will be used.
-
-If KEEP is a non-nil value, keep the generated patches. The default
-behavior is to delete them after sending email."
- (interactive "P")
- (let* ((rev (or (seq-some (lambda (fn)
- (funcall fn))
- git-email-get-revision-functions)
- (git-email--minibuffer-get-revision)))
- (version (if args
- (read-from-minibuffer "Version: " "2")
- "1"))
- (args (if args
- (apply
- #'concat (mapcar
- (lambda (a) (concat a " "))
- (completing-read-multiple
- "Args: "
- git-email-format-patch-extra-args)))
- git-email-format-patch-default-args))
- ;; List of patches generated, the last element is an empty string
- ;; so remove it. Reverse the list so we edit the cover letter first.
- (files (nreverse (butlast
- (split-string
- (shell-command-to-string
- (format "git format-patch %s -v %s %s"
- args version rev))
- "\n")))))
+ARGS are additional arguments to give to 'git format-patch'. By
+default, the arguments in `git-email-format-patch-default-args'
+will be used.
+
+Patches for the commits in RANGE will be created.
+
+With prefix argument KEEP, keep the generated patches. The
+default behavior is to delete them after sending the message."
+ (interactive
+ (list (apply #'concat (mapcar
+ (lambda (a) (concat a ""))
+ (completing-read-multiple
+ "Args: " git-email-format-patch-extra-args
+ nil nil git-email-format-patch-default-args)))
+ (or (seq-some (lambda (fn)
+ (funcall fn))
+ git-email-get-revision-functions)
+ (git-email--minibuffer-get-revision))
+ current-prefix-arg))
+ ;; List of patches generated, the last element is an empty string
+ ;; so remove it. Reverse the list so we edit the cover letter first.
+ (let ((files (nreverse (butlast
+ (split-string
+ (shell-command-to-string
+ (format "git format-patch %s %s"
+ args range))
+ "\n")))))
(dolist (file files)
(run-hooks 'git-email-pre-compose-email-hook)
(git-email--compose-email file)
(run-hooks 'git-email-post-compose-email-hook))
- (mapc #'delete-file files)))
+ (unless keep
+ (mapc #'delete-file files))))
;;;; Operate on emails
(defun git-email-send-all ()