From b3b837cc730f6040f21a6b612c035f5129d02a89 Mon Sep 17 00:00:00 2001 From: Xinglu Chen Date: Sun, 7 Feb 2021 23:42:49 +0100 Subject: Handle error if no "to" address is found Previously `substring` would give an error if the "to" address from "git config --list" was empty. This meant that no message would be created. This patch fixes this and instead returns an empty string if to "to" address was found. Signed-off-by: Xinglu Chen --- git-email.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'git-email.el') diff --git a/git-email.el b/git-email.el index e79f486..3837d8b 100644 --- a/git-email.el +++ b/git-email.el @@ -273,9 +273,11 @@ If the header is not found, return an empty string." This runs \“git config --list\" in the current directory so might not always work." - (substring - (shell-command-to-string "git config --list | grep sendemail.to") - 13 -1)) ; Remove newline + (let* ((to (shell-command-to-string "git config --list | grep sendemail.to")) + (address (if (string= "" to) + "" + (substring to 13 -1)))) ; Remove newline + address)) (defun git-email--compose-email (patch-file) "Given a PATCH-FILE, compose an email. -- cgit v1.2.3