summaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-09-03 12:37:01 -0700
committerJunio C Hamano <gitster@pobox.com>2020-09-03 12:37:01 -0700
commit9c31b19dd00981fcea435de1cd05eab179039a8d (patch)
tree970ac78108fa329c76070f30ed1b3280add80c87 /ident.c
parente19713638985533ce461db072b49112da5bd2042 (diff)
parent6160b2e9a486f5dc29f621e94a0e5dcce0ab3d52 (diff)
downloadgit-9c31b19dd00981fcea435de1cd05eab179039a8d.tar.gz
Merge branch 'pw/rebase-i-more-options'
"git rebase -i" learns a bit more options. * pw/rebase-i-more-options: t3436: do not run git-merge-recursive in dashed form rebase: add --reset-author-date rebase -i: support --ignore-date rebase -i: support --committer-date-is-author-date am: stop exporting GIT_COMMITTER_DATE rebase -i: add --ignore-whitespace flag
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/ident.c b/ident.c
index 813741c06c..6aba4b5cb6 100644
--- a/ident.c
+++ b/ident.c
@@ -375,11 +375,15 @@ static void ident_env_hint(enum want_ident whose_ident)
const char *fmt_ident(const char *name, const char *email,
enum want_ident whose_ident, const char *date_str, int flag)
{
- static struct strbuf ident = STRBUF_INIT;
+ static int index;
+ static struct strbuf ident_pool[2] = { STRBUF_INIT, STRBUF_INIT };
int strict = (flag & IDENT_STRICT);
int want_date = !(flag & IDENT_NO_DATE);
int want_name = !(flag & IDENT_NO_NAME);
+ struct strbuf *ident = &ident_pool[index];
+ index = (index + 1) % ARRAY_SIZE(ident_pool);
+
if (!email) {
if (whose_ident == WANT_AUTHOR_IDENT && git_author_email.len)
email = git_author_email.buf;
@@ -435,25 +439,25 @@ const char *fmt_ident(const char *name, const char *email,
die(_("name consists only of disallowed characters: %s"), name);
}
- strbuf_reset(&ident);
+ strbuf_reset(ident);
if (want_name) {
- strbuf_addstr_without_crud(&ident, name);
- strbuf_addstr(&ident, " <");
+ strbuf_addstr_without_crud(ident, name);
+ strbuf_addstr(ident, " <");
}
- strbuf_addstr_without_crud(&ident, email);
+ strbuf_addstr_without_crud(ident, email);
if (want_name)
- strbuf_addch(&ident, '>');
+ strbuf_addch(ident, '>');
if (want_date) {
- strbuf_addch(&ident, ' ');
+ strbuf_addch(ident, ' ');
if (date_str && date_str[0]) {
- if (parse_date(date_str, &ident) < 0)
+ if (parse_date(date_str, ident) < 0)
die(_("invalid date format: %s"), date_str);
}
else
- strbuf_addstr(&ident, ident_default_date());
+ strbuf_addstr(ident, ident_default_date());
}
- return ident.buf;
+ return ident->buf;
}
const char *fmt_name(enum want_ident whose_ident)