replace: add tests for --edit
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 17, 2014 at 14:16 UTC
85f98fc037ae026596c5d3b5d71fbfaa9144f210
1 file changed
+27
t/t6050-replace.sh
+27
@@ -318,6 +318,33 @@ test_expect_success 'test --format long' '
318
test_cmp expected actual
319
'
320
321
+test_expect_success 'setup a fake editor' '
322
+ write_script fakeeditor <<-\EOF
323
+ sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
324
+ mv "$1.new" "$1"
325
+ EOF
326
+'
327
+
328
+test_expect_success '--edit with and without already replaced object' '
329
+ test_must_fail env GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
330
+ GIT_EDITOR=./fakeeditor git replace --force --edit "$PARA3" &&
331
+ git replace -l | grep "$PARA3" &&
332
+ git cat-file commit "$PARA3" | grep "A fake Thor" &&
333
+ git replace -d "$PARA3" &&
334
+ GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
335
+ git replace -l | grep "$PARA3" &&
336
+ git cat-file commit "$PARA3" | grep "A fake Thor"
337
+'
338
+
339
+test_expect_success '--edit and change nothing or command failed' '
340
+ git replace -d "$PARA3" &&
341
+ test_must_fail env GIT_EDITOR=true git replace --edit "$PARA3" &&
342
+ test_must_fail env GIT_EDITOR="./fakeeditor;false" git replace --edit "$PARA3" &&
343
+ GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
344
+ git replace -l | grep "$PARA3" &&
345
+ git cat-file commit "$PARA3" | grep "A fake Thor"
346
+'
347
+
348
test_expect_success 'replace ref cleanup' '
349
test -n "$(git replace)" &&
350
git replace -d $(git replace) &&