summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-11-06 20:34:53 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-11-06 20:34:53 -0700
commit736064843a60ac1814da71550ae04c9673ed1e89 (patch)
tree28e90440a699ea395a7b68c7a3af9fda7940961a
parent23e42778e50eb030986ac6c5e98764f7775e359c (diff)
downloadmailscripts-736064843a60ac1814da71550ae04c9673ed1e89.tar.gz
mailscripts.el: if user does not enter a branch name, use HEAD
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--debian/changelog1
-rw-r--r--mailscripts.el23
2 files changed, 15 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog
index dc13036..919eb1a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ mailscripts (0.12-1) UNRELEASED; urgency=medium
Thanks to Daniel Kahn Gillmor for the patch series.
* mailscripts.el: add mailscripts-extract-patches-branch-prefix defcustom.
* mailscripts.el: add notmuch-extract-thread-patches-projectile command.
+ * mailscripts.el: if user does not enter a branch name, use current HEAD.
* mailscripts.el: add notmuch-extract-message-patches{,-projectile} commands.
* elpa-mailscripts now depends on elpa-projectile.
diff --git a/mailscripts.el b/mailscripts.el
index 6bc64bc..db1cf94 100644
--- a/mailscripts.el
+++ b/mailscripts.el
@@ -65,7 +65,8 @@ The target branch may or may not already exist.
See notmuch-extract-patch(1) manpage for limitations: in
particular, this Emacs Lisp function supports passing only entire
threads to the notmuch-extract-patch(1) command."
- (interactive "Dgit repo: \nsnew branch name: \nP")
+ (interactive
+ "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP")
(let ((thread-id notmuch-show-thread-id)
(default-directory (expand-file-name repo)))
(mailscripts--check-out-branch branch no-prefix)
@@ -93,7 +94,8 @@ The target branch may or may not already exist.
Patches are applied using git-am(1), so we only consider
attachments with filenames which look like they were generated by
git-format-patch(1)."
- (interactive "Dgit repo: \nsnew branch name: \nP")
+ (interactive
+ "Dgit repo: \nsbranch name (or leave blank to apply to current HEAD): \nP")
(with-current-notmuch-show-message
(let ((default-directory (expand-file-name repo))
(mm-handle (mm-dissect-buffer)))
@@ -116,17 +118,20 @@ git-format-patch(1)."
'notmuch-extract-message-patches no-prefix))
(defun mailscripts--check-out-branch (branch no-prefix)
- (call-process-shell-command
- (format "git checkout -b %s"
- (shell-quote-argument
- (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix)
- (concat mailscripts-extract-patches-branch-prefix branch)
- branch)))))
+ (unless (string= branch "")
+ (call-process-shell-command
+ (format "git checkout -b %s"
+ (shell-quote-argument
+ (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix)
+ (concat mailscripts-extract-patches-branch-prefix branch)
+ branch))))))
(defun mailscripts--projectile-repo-and-branch (f &optional no-prefix)
(let ((repo (projectile-completing-read
"Select projectile project: " projectile-known-projects))
- (branch (completing-read "Branch name: " nil)))
+ (branch (completing-read
+ "Branch name (or leave blank to apply to current HEAD): "
+ nil)))
(funcall f repo branch no-prefix)))
(provide 'mailscripts)