Subject: [PATCH 2/2] t3650: add more regression tests for failure conditions

From: [email-masked]
Date: Mon, 22 Dec 2025 23:04:43 +0100

From: Kristoffer Haugsbakk <[email-masked]>

There isn’t much test coverage for basic failure conditions. Let’s add
a few more since these are simple to write and remove if they become
obsolete.

Signed-off-by: Kristoffer Haugsbakk <[email-masked]>
---
 t/t3650-replay-basics.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/t/t3650-replay-basics.sh b/t/t3650-replay-basics.sh
index bfe8e01da49..c543d55857b 100755
--- a/t/t3650-replay-basics.sh
+++ b/t/t3650-replay-basics.sh
@@ -67,6 +67,33 @@ test_expect_success '--advance with invalid commit-ish' '
 	test_cmp expect actual
 '
 
+test_expect_success 'option --onto or --advance is mandatory' '
+	cat >expect <<-\EOF &&
+	error: option --onto or --advance is mandatory
+	EOF
+	# First line is the error; rest is Usage
+	test_must_fail git replay topic1..topic2 >&1 2>&1 |
+		head -1 >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'no base or negative ref gives no-replaying down to root error' '
+	cat >expect <<-\EOF &&
+	fatal: replaying down to root commit is not supported yet!
+	EOF
+	test_must_fail git replay --onto=topic1 topic2 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'options --advance and --contained cannot be used together' '
+	cat >expect <<-EOF &&
+	fatal: options ${SQ}--advance${SQ} and ${SQ}--contained${SQ} cannot be used together
+	EOF
+	test_must_fail git replay --advance=main --contained \
+		topic1..topic2 2>actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'using replay to rebase two branches, one on top of other' '
 	git replay --onto main topic1..topic2 >result &&
 
-- 
2.52.0.10.g08704017180