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>
Jeff King committed
Jan 12, 2015 at 20:58 UTC
eaa541eb59aefa2c5e9e160c36a259d372c25711
1 file changed
+3
-9
builtin/commit.c
+3
-9
@@ -566,20 +566,14 @@ static void set_ident_var(char **buf, char *val)
566
*buf = val;
567
}
568
569
-static char *envdup(const char *var)
570
-{
571
- const char *val = getenv(var);
572
- return val ? xstrdup(val) : NULL;
573
-}
574
-
569
static void determine_author_info(struct strbuf *author_ident)
570
{
571
char *name, *email, *date;
572
struct ident_split author;
573
580
- name = envdup("GIT_AUTHOR_NAME");
581
- email = envdup("GIT_AUTHOR_EMAIL");
582
- date = envdup("GIT_AUTHOR_DATE");
574
+ name = xstrdup_or_null(getenv("GIT_AUTHOR_NAME"));
575
+ email = xstrdup_or_null(getenv("GIT_AUTHOR_EMAIL"));
576
+ date = xstrdup_or_null(getenv("GIT_AUTHOR_DATE"));
577
578
if (author_message) {
579
struct ident_split ident;