diff --git a/config.c b/config.c index 3900e4947be92b..f6d4e2fae39d5e 100644 --- a/config.c +++ b/config.c @@ -2339,6 +2339,11 @@ int git_config_get_max_percent_split_change(void) int git_config_get_fsmonitor(void) { + if (!the_repository->worktree) { + core_fsmonitor = 0; + return 0; + } + if (git_config_get_pathname("core.fsmonitor", &core_fsmonitor)) core_fsmonitor = getenv("GIT_TEST_FSMONITOR"); diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 2dc853d1be5f0f..665ade0cf2b7a3 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -128,6 +128,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' ' test_expect_success POSIXPERM 'forced modes' ' + GIT_TEST_FSMONITOR="" && mkdir -p templates/hooks && echo update-server-info >templates/hooks/post-update && chmod +x templates/hooks/post-update && diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index 9974457f5615c9..28dce0c26f66dd 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -775,6 +775,7 @@ test_expect_success '#29: setup' ' setup_repo 29 non-existent gitfile true && mkdir -p 29/sub/sub 29/wt/sub && ( + GIT_TEST_FSMONITOR="" && cd 29 && GIT_WORK_TREE="$here/29" && export GIT_WORK_TREE && diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index e819ba741ec960..d4d3cbae0fe971 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -1,5 +1,7 @@ #!/bin/sh +GIT_TEST_FSMONITOR="" + test_description='test git worktree add' . ./test-lib.sh diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index ff641b348a1bac..62f645d6392919 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -520,6 +520,7 @@ test_expect_success 'reset and bind merge' ' test_expect_success 'merge-recursive w/ empty work tree - ours has rename' ' ( + GIT_TEST_FSMONITOR="" && GIT_WORK_TREE="$PWD/ours-has-rename-work" && export GIT_WORK_TREE && GIT_INDEX_FILE="$PWD/ours-has-rename-index" && @@ -545,6 +546,7 @@ test_expect_success 'merge-recursive w/ empty work tree - ours has rename' ' test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' ' ( + GIT_TEST_FSMONITOR="" && GIT_WORK_TREE="$PWD/theirs-has-rename-work" && export GIT_WORK_TREE && GIT_INDEX_FILE="$PWD/theirs-has-rename-index" && diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 461dd539ffd480..9dc7d1aefb6576 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -697,6 +697,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' ' test_expect_success 'submodule rebase setup' ' + GIT_TEST_FSMONITOR="" && git checkout A && mkdir sub && ( diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 66282a720ee853..64269bd89d5077 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -355,6 +355,7 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' ' ' test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' ' + GIT_TEST_FSMONITOR="" && git reset --hard && git submodule update && git -C submod checkout HEAD^ && diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index 9dcb69df5c3684..017417790ecb51 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -15,6 +15,9 @@ This test tries to verify the sanity of --submodule=diff option of git diff. # Tested non-UTF-8 encoding test_encoding="ISO8859-1" +# fsmonitor does not work well with submodules +GIT_TEST_FSMONITOR="" + # String "added" in German (translated with Google Translate), encoded in UTF-8, # used in sample commit log messages in add_file() function below. added=$(printf "hinzugef\303\274gt") diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 63205dfdf962dc..fb346bff058fc9 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -1,6 +1,8 @@ #!/bin/sh # Copyright (c) 2010, Jens Lehmann +GIT_TEST_FSMONITOR="" + test_description='Recursive "git fetch" for submodules' . ./test-lib.sh diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index 190ae149cf3cb6..c433738a3a216a 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -4,6 +4,9 @@ test_description='test untracked cache' . ./test-lib.sh +# fsmonitor changes the expected behvaior of GIT_TRACE_UNTRACKED_STATS +GIT_TEST_FSMONITOR="" + # On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime # is updated lazily after contents in the directory changes, which # forces the untracked cache code to take the slow path. A test diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index 8e32f190077474..c78e9009cfab89 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -7,6 +7,9 @@ test_description='Test rebasing, stashing, etc. with submodules' . ./test-lib.sh +# fsmonitor does not work well with submodules +GIT_TEST_FSMONITOR="" + test_expect_success setup ' echo file > file && diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index c973278300a5c9..8d93aaef5f8eca 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -11,6 +11,8 @@ submodule and "git submodule update --rebase/--merge" does not detach the HEAD. . ./test-lib.sh +# fsmonitor does not work well with submodules +GIT_TEST_FSMONITOR="" compare_head() { diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh index 08629a6e702999..1a716f2c2ae49e 100755 --- a/t/t7506-status-submodule.sh +++ b/t/t7506-status-submodule.sh @@ -4,6 +4,9 @@ test_description='git status for submodule' . ./test-lib.sh +# fsmonitor does not work well with submodules +GIT_TEST_FSMONITOR="" + test_create_repo_with_commit () { test_create_repo "$1" && ( diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 4e676cdce8d621..bf0487632d1108 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -846,6 +846,9 @@ test_expect_success 'status refreshes the index' ' test_cmp expect output ' +# fsmonitor does not work well with submodules +GIT_TEST_FSMONITOR="" + test_expect_success 'setup status submodule summary' ' test_create_repo sm && ( cd sm && diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 81a375fa0ff984..443d2e653b7e9f 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -8,6 +8,9 @@ test_description='git status with file system watcher' # "git update-index --fsmonitor" can be used to get the extension written # before testing the results. +# Disable an external value, as we will set it directly as needed. +GIT_TEST_FSMONITOR="" + clean_repo () { git reset --hard HEAD && git clean -fd diff --git a/t/t7519/fsmonitor-watchman b/t/t7519/fsmonitor-watchman index d8e7a1e5ba85c0..06312876aa44bf 100755 --- a/t/t7519/fsmonitor-watchman +++ b/t/t7519/fsmonitor-watchman @@ -94,7 +94,6 @@ sub launch_watchman { my $o = $json_pkg->new->utf8->decode($response); if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { - print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; $retry--; qx/watchman watch "$git_work_tree"/; die "Failed to make watchman watch '$git_work_tree'.\n" . diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index e0b3f28d3a96e1..ef840ce0975b38 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1475,3 +1475,18 @@ test_set_port () { port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0})) eval $var=$port } + +test_clear_watchman () { + if test -n "$GIT_TEST_FSMONITOR" + then + watchman watch-list | + grep "$TRASH_DIRECTORY" | + sed "s/\",//g" | + sed "s/\"//g" >repo-list + + while read repo + do + watchman watch-del "$repo" + done