aboutsummaryrefslogtreecommitdiff
path: root/git-email.el
diff options
context:
space:
mode:
Diffstat (limited to 'git-email.el')
-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 ()