diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2018-08-07 11:34:51 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-07 23:52:06 +0200 |
commit | 5dfcfe1eb28edd1afe8e2e738878b71a7c69d301 (patch) | |
tree | 7a7b92e58b73b37993409b787f6373c579887532 /sequencer.c | |
parent | sequencer: don't die() on bogus user-edited timestamp (diff) | |
download | git-5dfcfe1eb28edd1afe8e2e738878b71a7c69d301.tar.xz git-5dfcfe1eb28edd1afe8e2e738878b71a7c69d301.zip |
sequencer: handle errors from read_author_ident()
Check for a NULL return value from read_author_ident() that indicates
an error. Previously the NULL author was passed to commit_tree() which
would then fallback to using the default author when creating the new
commit. This changed the date and potentially the author of the commit
which corrupted the author data compared to its expected value.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c index 944dea6997..c4e4418559 100644 --- a/sequencer.c +++ b/sequencer.c @@ -795,11 +795,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts, if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) { struct strbuf msg = STRBUF_INIT, script = STRBUF_INIT; - const char *author = is_rebase_i(opts) ? - read_author_ident(&script) : NULL; + const char *author = NULL; struct object_id root_commit, *cache_tree_oid; int res = 0; + if (is_rebase_i(opts)) { + author = read_author_ident(&script); + if (!author) { + strbuf_release(&script); + return -1; + } + } + if (!defmsg) BUG("root commit without message"); |