Skip to content

Commit 5dfcfe1

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5522bba commit 5dfcfe1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sequencer.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,11 +795,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
795795

796796
if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) {
797797
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;
800799
struct object_id root_commit, *cache_tree_oid;
801800
int res = 0;
802801

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+
803810
if (!defmsg)
804811
BUG("root commit without message");
805812

0 commit comments

Comments
 (0)