Imported Upstream version 2.25.4
[platform/upstream/git.git] / t / t7519-status-fsmonitor.sh
index 81a375f..cf0fda2 100755 (executable)
@@ -106,6 +106,8 @@ EOF
 
 # test that "update-index --fsmonitor-valid" sets the fsmonitor valid bit
 test_expect_success 'update-index --fsmonitor-valid" sets the fsmonitor valid bit' '
+       write_script .git/hooks/fsmonitor-test<<-\EOF &&
+       EOF
        git update-index --fsmonitor &&
        git update-index --fsmonitor-valid dir1/modified &&
        git update-index --fsmonitor-valid dir2/modified &&
@@ -164,6 +166,8 @@ EOF
 
 # test that newly added files are marked valid
 test_expect_success 'newly added files are marked valid' '
+       write_script .git/hooks/fsmonitor-test<<-\EOF &&
+       EOF
        git add new &&
        git add dir1/new &&
        git add dir2/new &&
@@ -218,11 +222,12 @@ test_expect_success '*only* files returned by the integration script get flagged
 # Ensure commands that call refresh_index() to move the index back in time
 # properly invalidate the fsmonitor cache
 test_expect_success 'refresh_index() invalidates fsmonitor cache' '
-       write_script .git/hooks/fsmonitor-test<<-\EOF &&
-       EOF
        clean_repo &&
        dirty_repo &&
+       write_integration_script &&
        git add . &&
+       write_script .git/hooks/fsmonitor-test<<-\EOF &&
+       EOF
        git commit -m "to reset" &&
        git reset HEAD~1 &&
        git status >actual &&
@@ -294,7 +299,7 @@ do
        done
 done
 
-# test that splitting the index dosn't interfere
+# test that splitting the index doesn't interfere
 test_expect_success 'splitting the index results in the same state' '
        write_integration_script &&
        dirty_repo &&
@@ -354,4 +359,23 @@ test_expect_success 'discard_index() also discards fsmonitor info' '
        test_cmp expect actual
 '
 
+# Test unstaging entries that:
+#  - Are not flagged with CE_FSMONITOR_VALID
+#  - Have a position in the index >= the number of entries present in the index
+#    after unstaging.
+test_expect_success 'status succeeds after staging/unstaging' '
+       test_create_repo fsmonitor-stage-unstage &&
+       (
+               cd fsmonitor-stage-unstage &&
+               test_commit initial &&
+               git update-index --fsmonitor &&
+               removed=$(test_seq 1 100 | sed "s/^/z/") &&
+               touch $removed &&
+               git add $removed &&
+               git config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-env" &&
+               FSMONITOR_LIST="$removed" git restore -S $removed &&
+               FSMONITOR_LIST="$removed" git status
+       )
+'
+
 test_done