diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-12-02 13:43:34 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-02 23:35:46 -0800 |
commit | d9ccfe7711a8bf1ed9d9cd87daa9863e0d564b23 (patch) | |
tree | 61fbb63b219435a6026f1cb8c436a32d975895a1 /ident.c | |
parent | b5b644a93adb41bca590a3cdfd9b64ccf3614f50 (diff) | |
download | git-d9ccfe7711a8bf1ed9d9cd87daa9863e0d564b23.tar.gz |
Fix --signoff in builtin-commit differently.
Introduce fmt_name() specifically meant for formatting the name and
email pair, to add signed-off-by value. This reverts parts of
13208572fbe8838fd8835548d7502202d1f7b21d (builtin-commit: fix --signoff)
so that an empty datestamp string given to fmt_ident() by mistake will
error out as before.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ident.c')
-rw-r--r-- | ident.c | 34 |
1 files changed, 24 insertions, 10 deletions
@@ -192,12 +192,14 @@ static const char *env_hint = "Omit --global to set the identity only in this repository.\n" "\n"; -const char *fmt_ident(const char *name, const char *email, - const char *date_str, int error_on_no_name) +static const char *fmt_ident_1(const char *name, const char *email, + const char *date_str, int flag) { static char buffer[1000]; char date[50]; int i; + int error_on_no_name = !!(flag & 01); + int name_addr_only = !!(flag & 02); setup_ident(); if (!name) @@ -224,24 +226,36 @@ const char *fmt_ident(const char *name, const char *email, } strcpy(date, git_default_date); - if (date_str) { - if (*date_str) - parse_date(date_str, date, sizeof(date)); - else - date[0] = '\0'; - } + if (!name_addr_only && date_str) + parse_date(date_str, date, sizeof(date)); i = copy(buffer, sizeof(buffer), 0, name); i = add_raw(buffer, sizeof(buffer), i, " <"); i = copy(buffer, sizeof(buffer), i, email); - i = add_raw(buffer, sizeof(buffer), i, date[0] ? "> " : ">"); - i = copy(buffer, sizeof(buffer), i, date); + if (!name_addr_only) { + i = add_raw(buffer, sizeof(buffer), i, "> "); + i = copy(buffer, sizeof(buffer), i, date); + } else { + i = add_raw(buffer, sizeof(buffer), i, ">"); + } if (i >= sizeof(buffer)) die("Impossibly long personal identifier"); buffer[i] = 0; return buffer; } +const char *fmt_ident(const char *name, const char *email, + const char *date_str, int error_on_no_name) +{ + int flag = (error_on_no_name ? 01 : 0); + return fmt_ident_1(name, email, date_str, flag); +} + +const char *fmt_name(const char *name, const char *email) +{ + return fmt_ident_1(name, email, NULL, 03); +} + const char *git_author_info(int error_on_no_name) { return fmt_ident(getenv("GIT_AUTHOR_NAME"), |