Skip to content

Commit 85f98fc

Browse files
chriscoolgitster
authored andcommitted
replace: add tests for --edit
Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2479083 commit 85f98fc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/t6050-replace.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,33 @@ test_expect_success 'test --format long' '
318318
test_cmp expected actual
319319
'
320320

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+
321348
test_expect_success 'replace ref cleanup' '
322349
test -n "$(git replace)" &&
323350
git replace -d $(git replace) &&

0 commit comments

Comments
 (0)