replay: die() instead of failing assert()

It's not a good idea for regular Git commands to use an assert() to check for things that could happen but are not supported. Let's die() with an explanation of the issue instead. Co-authored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Nov 24, 2023 at 12:10 UTC a9df61ace31b84c9609dfa4875e93b8c92e06e56
1 file changed +6 -1
builtin/replay.c
+6 -1
@@ -179,7 +179,12 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
179
180 fprintf(stderr, "Rebasing %s...\r",
181 oid_to_hex(&commit->object.oid));
182 - assert(commit->parents && !commit->parents->next);
182 +
183 + if (!commit->parents)
184 + die(_("replaying down to root commit is not supported yet!"));
185 + if (commit->parents->next)
186 + die(_("replaying merge commits is not supported yet!"));
187 +
188 base = commit->parents->item;
189
190 next_tree = repo_get_commit_tree(the_repository, commit);