summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-01-13 01:58:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-01-13 18:03:40 (GMT)
commiteaa541eb59aefa2c5e9e160c36a259d372c25711 (patch)
treef6fc71bdcff03eb105a32bcfbb3b4833a48a0e52 /builtin
parent444069078687fc00586824a21eff9758fc4d0625 (diff)
downloadgit-eaa541eb59aefa2c5e9e160c36a259d372c25711.zip
git-eaa541eb59aefa2c5e9e160c36a259d372c25711.tar.gz
git-eaa541eb59aefa2c5e9e160c36a259d372c25711.tar.bz2
builtin/commit.c: use xstrdup_or_null instead of envdup
The only reason for envdup to be its own function is that we have to save the result in a temporary string. With xstrdup_or_null, we can feed the result of getenv() directly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index b0fe784..b1cf284 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -566,20 +566,14 @@ static void set_ident_var(char **buf, char *val)
*buf = val;
}
-static char *envdup(const char *var)
-{
- const char *val = getenv(var);
- return val ? xstrdup(val) : NULL;
-}
-
static void determine_author_info(struct strbuf *author_ident)
{
char *name, *email, *date;
struct ident_split author;
- name = envdup("GIT_AUTHOR_NAME");
- email = envdup("GIT_AUTHOR_EMAIL");
- date = envdup("GIT_AUTHOR_DATE");
+ name = xstrdup_or_null(getenv("GIT_AUTHOR_NAME"));
+ email = xstrdup_or_null(getenv("GIT_AUTHOR_EMAIL"));
+ date = xstrdup_or_null(getenv("GIT_AUTHOR_DATE"));
if (author_message) {
struct ident_split ident;