summaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ident.c b/ident.c
index 59beef2f35..8b5080dfe6 100644
--- a/ident.c
+++ b/ident.c
@@ -269,13 +269,14 @@ const char *fmt_ident(const char *name, const char *email,
char date[50];
int error_on_no_name = (flag & IDENT_ERROR_ON_NO_NAME);
int want_date = !(flag & IDENT_NO_DATE);
+ int want_name = !(flag & IDENT_NO_NAME);
- if (!name)
+ if (want_name && !name)
name = ident_default_name();
if (!email)
email = ident_default_email();
- if (!*name) {
+ if (want_name && !*name) {
struct passwd *pw;
if (error_on_no_name) {
@@ -297,10 +298,13 @@ const char *fmt_ident(const char *name, const char *email,
}
strbuf_reset(&ident);
- strbuf_addstr_without_crud(&ident, name);
- strbuf_addstr(&ident, " <");
+ if (want_name) {
+ strbuf_addstr_without_crud(&ident, name);
+ strbuf_addstr(&ident, " <");
+ }
strbuf_addstr_without_crud(&ident, email);
- strbuf_addch(&ident, '>');
+ if (want_name)
+ strbuf_addch(&ident, '>');
if (want_date) {
strbuf_addch(&ident, ' ');
strbuf_addstr_without_crud(&ident, date);