t3650: add more regression tests for failure conditions

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. Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristoffer Haugsbakk committed Jan 5, 2026 at 20:53 UTC 56b77a687eaf9c48482e9f59ab7077e442e85ff5
1 file changed +40
t/t3650-replay-basics.sh
+40
@@ -43,6 +43,13 @@ test_expect_success 'setup' '
43 test_commit L &&
44 test_commit M &&
45
46 + git switch --detach topic4 &&
47 + test_commit N &&
48 + test_commit O &&
49 + git switch -c topic-with-merge topic4 &&
50 + test_merge P O --no-ff &&
51 + git switch main &&
52 +
53 git switch -c conflict B &&
54 test_commit C.conflict C.t conflict
55 '
@@ -65,6 +72,39 @@ test_expect_success '--onto with invalid commit-ish' '
72 test_cmp expect actual
73 '
74
75 +test_expect_success 'option --onto or --advance is mandatory' '
76 + echo "error: option --onto or --advance is mandatory" >expect &&
77 + test_might_fail git replay -h >>expect &&
78 + test_must_fail git replay topic1..topic2 2>actual &&
79 + test_cmp expect actual
80 +'
81 +
82 +test_expect_success 'no base or negative ref gives no-replaying down to root error' '
83 + echo "fatal: replaying down from root commit is not supported yet!" >expect &&
84 + test_must_fail git replay --onto=topic1 topic2 2>actual &&
85 + test_cmp expect actual
86 +'
87 +
88 +test_expect_success 'options --advance and --contained cannot be used together' '
89 + printf "fatal: options ${SQ}--advance${SQ} " >expect &&
90 + printf "and ${SQ}--contained${SQ} cannot be used together\n" >>expect &&
91 + test_must_fail git replay --advance=main --contained \
92 + topic1..topic2 2>actual &&
93 + test_cmp expect actual
94 +'
95 +
96 +test_expect_success 'cannot advance target ... ordering would be ill-defined' '
97 + echo "fatal: cannot advance target with multiple sources because ordering would be ill-defined" >expect &&
98 + test_must_fail git replay --advance=main main topic1 topic2 2>actual &&
99 + test_cmp expect actual
100 +'
101 +
102 +test_expect_success 'replaying merge commits is not supported yet' '
103 + echo "fatal: replaying merge commits is not supported yet!" >expect &&
104 + test_must_fail git replay --advance=main main..topic-with-merge 2>actual &&
105 + test_cmp expect actual
106 +'
107 +
108 test_expect_success 'using replay to rebase two branches, one on top of other' '
109 git replay --ref-action=print --onto main topic1..topic2 >result &&
110