File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff 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+
321348test_expect_success ' replace ref cleanup' '
322349 test -n "$(git replace)" &&
323350 git replace -d $(git replace) &&
You can’t perform that action at this time.
0 commit comments