268
test_cmp expect-reflog reflog-msg
269
'
270
271
+test_expect_success 'replay.refAction=print config option' '
272
+ # Store original state
273
+ START=$(git rev-parse topic2) &&
274
+ test_when_finished "git branch -f topic2 $START" &&
275
+
276
+ # Test with config set to print
277
+ test_config replay.refAction print &&
278
+ git replay --onto main topic1..topic2 >output &&
279
+ test_line_count = 1 output &&
280
+ test_grep "^update refs/heads/topic2 " output
281
+'
282
+
283
+test_expect_success 'replay.refAction=update config option' '
284
+ # Store original state
285
+ START=$(git rev-parse topic2) &&
286
+ test_when_finished "git branch -f topic2 $START" &&
287
+
288
+ # Test with config set to update
289
+ test_config replay.refAction update &&
290
+ git replay --onto main topic1..topic2 >output &&
291
+ test_must_be_empty output &&
292
+
293
+ # Verify ref was updated
294
+ git log --format=%s topic2 >actual &&
295
+ test_write_lines E D M L B A >expect &&
296
+ test_cmp expect actual
297
+'
298
+
299
+test_expect_success 'command-line --ref-action overrides config' '
300
+ # Store original state
301
+ START=$(git rev-parse topic2) &&
302
+ test_when_finished "git branch -f topic2 $START" &&
303
+
304
+ # Set config to update but use --ref-action=print
305
+ test_config replay.refAction update &&
306
+ git replay --ref-action=print --onto main topic1..topic2 >output &&
307
+ test_line_count = 1 output &&
308
+ test_grep "^update refs/heads/topic2 " output
309
+'
310
+
311
+test_expect_success 'invalid replay.refAction value' '
312
+ test_config replay.refAction invalid &&
313
+ test_must_fail git replay --onto main topic1..topic2 2>error &&
314
+ test_grep "invalid.*replay.refAction.*value" error
315
+'
316
+
317
test_done