read-tree: add t1013 for submodule updates
[gitweb.git] / t / t7102-reset.sh
index 8d4b50d1b5816d69ab165119773a7ffc0c360c0a..ee703bed64cc7572cb9a86fce2b0157026475709 100755 (executable)
@@ -22,6 +22,9 @@ commit_msg () {
        fi
 }
 
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 test_expect_success 'creating initial files and commits' '
        test_tick &&
        echo "1st file" >first &&
@@ -41,7 +44,7 @@ test_expect_success 'creating initial files and commits' '
 
        echo "1st line 2nd file" >secondfile &&
        echo "2nd line 2nd file" >>secondfile &&
-       git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+       git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
        head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -64,10 +67,10 @@ test_expect_success 'reset --hard message' '
        test_cmp .expected .actual
 '
 
-test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
+test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
        hex=$(git log -1 --format="%h") &&
-       git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
-       echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
+       git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
+       echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
        test_cmp .expected .actual
 '
 
@@ -331,7 +334,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
        echo "1st line 2nd file" >secondfile &&
        echo "2nd line 2nd file" >>secondfile &&
-       git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
+       git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
        check_changes $head5
 '
 
@@ -535,4 +538,30 @@ test_expect_success 'reset with paths accepts tree' '
        git diff HEAD --exit-code
 '
 
+test_expect_success 'reset -N keeps removed files as intent-to-add' '
+       echo new-file >new-file &&
+       git add new-file &&
+       git reset -N HEAD &&
+
+       tree=$(git write-tree) &&
+       git ls-tree $tree new-file >actual &&
+       >expect &&
+       test_cmp expect actual &&
+
+       git diff --name-only >actual &&
+       echo new-file >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'reset --mixed sets up work tree' '
+       git init mixed_worktree &&
+       (
+               cd mixed_worktree &&
+               test_commit dummy
+       ) &&
+       : >expect &&
+       git --git-dir=mixed_worktree/.git --work-tree=mixed_worktree reset >actual &&
+       test_cmp expect actual
+'
+
 test_done