Code

Move commit_list_count() to commit.c
[git.git] / t / t7102-reset.sh
index cea9afb764226d3086450cb7c53c881bb9803eec..39ba14148c953d17589450917975372802eecfed 100755 (executable)
@@ -34,13 +34,13 @@ test_expect_success 'creating initial files and commits' '
 
 check_changes () {
        test "$(git rev-parse HEAD)" = "$1" &&
-       git diff | git diff .diff_expect - &&
-       git diff --cached | git diff .cached_expect - &&
+       git diff | test_cmp .diff_expect - &&
+       git diff --cached | test_cmp .cached_expect - &&
        for FILE in *
        do
                echo $FILE':'
                cat $FILE || return
-       done | git diff .cat_expect -
+       done | test_cmp .cat_expect -
 }
 
 >.diff_expect
@@ -59,6 +59,15 @@ test_expect_success 'giving a non existing revision should fail' '
        check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
 '
 
+test_expect_success 'reset --soft with unmerged index should fail' '
+       touch .git/MERGE_HEAD &&
+       echo "100644 44c5b5884550c17758737edcced463447b91d42b 1 un" |
+               git update-index --index-info &&
+       ! git reset --soft HEAD &&
+       rm .git/MERGE_HEAD &&
+       git rm --cached -- un
+'
+
 test_expect_success \
        'giving paths with options different than --mixed should fail' '
        ! git reset --soft -- first &&
@@ -381,9 +390,9 @@ test_expect_success 'test --mixed <paths>' '
        git add file1 file3 file4 &&
        ! git reset HEAD -- file1 file2 file3 &&
        git diff > output &&
-       git diff output expect &&
+       test_cmp output expect &&
        git diff --cached > output &&
-       git diff output cached_expect
+       test_cmp output cached_expect
 '
 
 test_expect_success 'test resetting the index at give paths' '
@@ -409,4 +418,14 @@ test_expect_success 'resetting an unmodified path is a no-op' '
        git diff-index --cached --exit-code HEAD
 '
 
+cat > expect << EOF
+file2: needs update
+EOF
+
+test_expect_success '--mixed refreshes the index' '
+       echo 123 >> file2 &&
+       git reset --mixed HEAD > output &&
+       test_cmp expect output
+'
+
 test_done