From 5366f2fa8e73fcf5bc11d6c176cd4a27ab2f56ad Mon Sep 17 00:00:00 2001 From: Xinglu Chen Date: Sat, 24 Apr 2021 13:09:42 +0200 Subject: git-email-magit: Escape string with with whitespace. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this strings with whitespaces would cause ‘git format-patch’ to fail. * git-email-magit.el (git-email--escape-string): New function. (git-email-magit-patch-send): Use it. --- git-email-magit.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git-email-magit.el b/git-email-magit.el index 1f6404e..fd4e001 100644 --- a/git-email-magit.el +++ b/git-email-magit.el @@ -34,11 +34,17 @@ (require 'magit-patch) (require 'magit-log) +(defun git-email--escape-string (str) + "Escape STR if it has spaces in it." + (if (string-match-p "\s" str) + (format "\"%s\"" str) + str)) + ;;;###autoload (defun git-email-magit-patch-send (args &optional commit) (interactive (let ((args (transient-args 'magit-patch-create))) - (list (mapconcat #'identity + (list (mapconcat #'git-email--escape-string (seq-filter #'stringp args) " ")))) ;; For some reason, `git-email-format-patch' gets called before -- cgit v1.2.3