aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinglu Chen <public@yoctocell.xyz>2021-02-07 23:42:49 +0100
committerXinglu Chen <public@yoctocell.xyz>2021-02-07 23:42:49 +0100
commitb3b837cc730f6040f21a6b612c035f5129d02a89 (patch)
treea996f9ed3a0d25df26a571ff2c0bc4060655f208
parentcf441170bc9c614f7e295c9eeb295ff18e2c9351 (diff)
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 <public@yoctocell.xyz>
-rw-r--r--git-email.el8
1 files changed, 5 insertions, 3 deletions
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.