signature: add git_signature_default_from_env

People who are doing a commit expect a unified timestamp between
author and committer information when we're using the current timestamp.
Provide a single function that returns both author and committer
information so that they can have an identical timestamp when none is
specified in the environment.
This commit is contained in:
Edward Thomson
2024-06-14 12:50:40 +02:00
parent 24d9fe1339
commit 649ef1cca6
7 changed files with 131 additions and 108 deletions

View File

@@ -130,8 +130,7 @@ static void create_initial_commit(git_repository *repo)
/** First use the config to initialize a commit signature for the user. */
if ((git_signature_default_author(&author_sig, repo) < 0) ||
(git_signature_default_committer(&committer_sig, repo) < 0))
if ((git_signature_default_from_env(&author_sig, &committer_sig, repo) < 0))
fatal("Unable to create a commit signature.",
"Perhaps 'user.name' and 'user.email' are not set");