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>

Phillip Wood committed Aug 7, 2018 at 10:34 UTC 5dfcfe1eb28edd1afe8e2e738878b71a7c69d301
1 file changed +9 -2
sequencer.c
+9 -2
@@ -795,11 +795,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
795
796 if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) {
797 struct strbuf msg = STRBUF_INIT, script = STRBUF_INIT;
798 - const char *author = is_rebase_i(opts) ?
799 - read_author_ident(&script) : NULL;
798 + const char *author = NULL;
799 struct object_id root_commit, *cache_tree_oid;
800 int res = 0;
801
802 + if (is_rebase_i(opts)) {
803 + author = read_author_ident(&script);
804 + if (!author) {
805 + strbuf_release(&script);
806 + return -1;
807 + }
808 + }
809 +
810 if (!defmsg)
811 BUG("root commit without message");
812