. ./test-lib.sh
commit_msg () {
- # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+ # String "modify 2nd file (changed)" partly in German
+ # (translated with Google Translate),
# encoded in UTF-8, used as a commit log message below.
- msg=$(printf "modify 2nd file (ge\303\244ndert)")
+ msg="modify 2nd file (ge\303\244ndert)\n"
if test -n "$1"
then
- msg=$(echo $msg | iconv -f utf-8 -t $1)
+ printf "$msg" | iconv -f utf-8 -t "$1"
+ else
+ printf "$msg"
fi
- echo $msg
}
test_expect_success 'creating initial files and commits' '
test_must_fail git diff --quiet -- secondfile &&
test -z "$(git diff --cached --name-only)" &&
test -f secondfile &&
- test ! -s secondfile
+ test_must_be_empty secondfile
'
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