summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-16 17:06:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-16 17:06:01 (GMT)
commit499168af3b2a21e2d234a2093cb3c0f64e2f36a0 (patch)
tree1e978002558fdcb1766bed41cb3b36d64c35430d /t
parent79e539404c016e894d8a4db8f43762842a066afc (diff)
parent4e4b125c239a78f3a8fe82e47d1f89fef510980c (diff)
downloadgit-499168af3b2a21e2d234a2093cb3c0f64e2f36a0.zip
git-499168af3b2a21e2d234a2093cb3c0f64e2f36a0.tar.gz
git-499168af3b2a21e2d234a2093cb3c0f64e2f36a0.tar.bz2
Merge branch 'cc/replace-edit'
"git replace" learns a new "--edit" option. * cc/replace-edit: Documentation: replace: describe new --edit option replace: add --edit to usage string replace: add tests for --edit replace: die early if replace ref already exists replace: refactor checking ref validity replace: make sure --edit results in a different object replace: add --edit option replace: factor object resolution out of replace_object replace: use OPT_CMDMODE to handle modes replace: refactor command-mode determination
Diffstat (limited to 't')
-rwxr-xr-xt/t6050-replace.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 719a116..68b3cb2 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -318,6 +318,33 @@ test_expect_success 'test --format long' '
test_cmp expected actual
'
+test_expect_success 'setup a fake editor' '
+ write_script fakeeditor <<-\EOF
+ sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
+ mv "$1.new" "$1"
+ EOF
+'
+
+test_expect_success '--edit with and without already replaced object' '
+ test_must_fail env GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
+ GIT_EDITOR=./fakeeditor git replace --force --edit "$PARA3" &&
+ git replace -l | grep "$PARA3" &&
+ git cat-file commit "$PARA3" | grep "A fake Thor" &&
+ git replace -d "$PARA3" &&
+ GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
+ git replace -l | grep "$PARA3" &&
+ git cat-file commit "$PARA3" | grep "A fake Thor"
+'
+
+test_expect_success '--edit and change nothing or command failed' '
+ git replace -d "$PARA3" &&
+ test_must_fail env GIT_EDITOR=true git replace --edit "$PARA3" &&
+ test_must_fail env GIT_EDITOR="./fakeeditor;false" git replace --edit "$PARA3" &&
+ GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
+ git replace -l | grep "$PARA3" &&
+ git cat-file commit "$PARA3" | grep "A fake Thor"
+'
+
test_expect_success 'replace ref cleanup' '
test -n "$(git replace)" &&
git replace -d $(git replace) &&