Skip to content

Commit eaa541e

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4440690 commit eaa541e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

builtin/commit.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,20 +566,14 @@ static void set_ident_var(char **buf, char *val)
566566
*buf = val;
567567
}
568568

569-
static char *envdup(const char *var)
570-
{
571-
const char *val = getenv(var);
572-
return val ? xstrdup(val) : NULL;
573-
}
574-
575569
static void determine_author_info(struct strbuf *author_ident)
576570
{
577571
char *name, *email, *date;
578572
struct ident_split author;
579573

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"));
583577

584578
if (author_message) {
585579
struct ident_split ident;

0 commit comments

Comments
 (0)