diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-18 12:36:25 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-19 06:31:32 -0500 |
commit | add30a838867820788c871c1d034fcf68c2ad12c (patch) | |
tree | 7266dc18143c766f6242c6dc05835ea5c2793746 /src/email.c | |
parent | b2c40314c7c8ae4b645f776f04dfe06983ad8ba3 (diff) | |
download | libgit2-ethomson/date.tar.gz |
date: rfc2822 formatting uses a `git_buf` instead of a static stringethomson/date
Diffstat (limited to 'src/email.c')
-rw-r--r-- | src/email.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/email.c b/src/email.c index 66ed2dd9f..e19a2928c 100644 --- a/src/email.c +++ b/src/email.c @@ -73,6 +73,19 @@ static int append_prefix( return git_str_oom(out) ? -1 : 0; } +static int append_date( + git_str *out, + const git_time *date) +{ + int error; + + if ((error = git_str_printf(out, "Date: ")) == 0 && + (error = git_date_rfc2822_fmt(out, date->time, date->offset)) == 0) + error = git_str_putc(out, '\n'); + + return error; +} + static int append_subject( git_str *out, size_t patch_idx, @@ -118,14 +131,12 @@ static int append_header( git_email_create_options *opts) { char id[GIT_OID_HEXSZ]; - char date[GIT_DATE_RFC2822_SZ]; int error; if ((error = git_oid_fmt(id, commit_id)) < 0 || (error = git_str_printf(out, "From %.*s %s\n", GIT_OID_HEXSZ, id, EMAIL_TIMESTAMP)) < 0 || (error = git_str_printf(out, "From: %s <%s>\n", author->name, author->email)) < 0 || - (error = git_date_rfc2822_fmt(date, sizeof(date), &author->when)) < 0 || - (error = git_str_printf(out, "Date: %s\n", date)) < 0 || + (error = append_date(out, &author->when)) < 0 || (error = append_subject(out, patch_idx, patch_count, summary, opts)) < 0) return error; |