Remove the assert in CommitData.parse() function
[stgit] / t / t3300-edit.sh
index 5772e48..09a2f25 100755 (executable)
@@ -5,7 +5,7 @@ test_description='Test "stg edit"'
 
 test_expect_success 'Setup' '
     printf "000\n111\n222\n333\n" >> foo &&
-    git add foo &&
+    stg add foo &&
     git commit -m "Initial commit" &&
     sed -i "s/000/000xx/" foo &&
     git commit -a -m "First change" &&
@@ -93,13 +93,13 @@ mkeditor ()
 {
     cat > "$1" <<EOF
 #!/bin/sh
-printf "\n$1\n" >> "\$1"
+printf "\n$1" >> "\$1"
 EOF
     chmod a+x "$1"
 }
 
 mkeditor vi
-test_expect_failure 'Edit commit message interactively (vi)' '
+test_expect_success 'Edit commit message interactively (vi)' '
     m=$(msg HEAD) &&
     PATH=.:$PATH stg edit p2 &&
     test "$(msg HEAD)" = "$m/vi"
@@ -114,14 +114,14 @@ test_expect_success 'Edit commit message interactively (EDITOR)' '
 '
 
 mkeditor e2
-test_expect_failure 'Edit commit message interactively (VISUAL)' '
+test_expect_success 'Edit commit message interactively (VISUAL)' '
     m=$(msg HEAD) &&
     VISUAL=./e2 EDITOR=./e1 PATH=.:$PATH stg edit p2 &&
     test "$(msg HEAD)" = "$m/e2"
 '
 
 mkeditor e3
-test_expect_failure 'Edit commit message interactively (core.editor)' '
+test_expect_success 'Edit commit message interactively (core.editor)' '
     m=$(msg HEAD) &&
     git config core.editor e3 &&
     VISUAL=./e2 EDITOR=./e1 PATH=.:$PATH stg edit p2 &&
@@ -137,7 +137,7 @@ test_expect_success 'Edit commit message interactively (stgit.editor)' '
 '
 
 mkeditor e5
-test_expect_failure 'Edit commit message interactively (GIT_EDITOR)' '
+test_expect_success 'Edit commit message interactively (GIT_EDITOR)' '
     m=$(msg HEAD) &&
     GIT_EDITOR=./e5 VISUAL=./e2 EDITOR=./e1 PATH=.:$PATH stg edit p2 &&
     test "$(msg HEAD)" = "$m/e5"
@@ -148,7 +148,7 @@ git config --unset core.editor
 git config --unset stgit.editor
 
 mkeditor twoliner
-test_expect_failure 'Both noninterative and interactive editing' '
+test_expect_success 'Both noninterative and interactive editing' '
     EDITOR=./twoliner stg edit -e -m "oneliner" p2 &&
     test "$(msg HEAD)" = "oneliner/twoliner"
 '
@@ -212,4 +212,19 @@ test_expect_failure 'Fail to set invalid author date' '
     test "$(date HEAD)" = "2013-01-28 22:30:00 -0300"
 '
 
+test_expect_success 'Set patch tree' '
+    p2tree=$(git log -1 --pretty=format:%T $(stg id p2)) &&
+    p4commit=$(stg id p4) &&
+    stg edit --set-tree $p4commit &&
+    test $(git write-tree) = $(git rev-parse ${p4commit}^{tree}) &&
+    grep "^333zz$" foo &&
+    stg pop &&
+    stg edit --set-tree $p2tree p2 &&
+    stg push --set-tree &&
+    test $(git write-tree) = $p2tree &&
+    grep "^333$" foo &&
+    stg edit --set-tree $p2tree p1 &&
+    test "$(echo $(stg series --empty --all))" = "+ p1 0> p2 - p3 ! p4"
+'
+
 test_done