2017-09-22 16:35:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git status with file system watcher'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
# Note, after "git reset --hard HEAD" no extensions exist other than 'TREE'
|
|
|
|
# "git update-index --fsmonitor" can be used to get the extension written
|
|
|
|
# before testing the results.
|
|
|
|
|
|
|
|
clean_repo () {
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
git clean -fd
|
|
|
|
}
|
|
|
|
|
|
|
|
dirty_repo () {
|
|
|
|
: >untracked &&
|
|
|
|
: >dir1/untracked &&
|
|
|
|
: >dir2/untracked &&
|
|
|
|
echo 1 >modified &&
|
|
|
|
echo 2 >dir1/modified &&
|
|
|
|
echo 3 >dir2/modified &&
|
|
|
|
echo 4 >new &&
|
|
|
|
echo 5 >dir1/new &&
|
|
|
|
echo 6 >dir2/new
|
|
|
|
}
|
|
|
|
|
|
|
|
write_integration_script () {
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --setup --clobber fsmonitor-test<<-\EOF
|
2017-09-22 16:35:46 +00:00
|
|
|
if test "$#" -ne 2
|
|
|
|
then
|
|
|
|
echo "$0: exactly 2 arguments expected"
|
|
|
|
exit 2
|
|
|
|
fi
|
2020-01-07 19:04:29 +00:00
|
|
|
if test "$1" != 2
|
2017-09-22 16:35:46 +00:00
|
|
|
then
|
|
|
|
echo "Unsupported core.fsmonitor hook version." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-01-07 19:04:29 +00:00
|
|
|
printf "last_update_token\0"
|
2017-09-22 16:35:46 +00:00
|
|
|
printf "untracked\0"
|
|
|
|
printf "dir1/untracked\0"
|
|
|
|
printf "dir2/untracked\0"
|
|
|
|
printf "modified\0"
|
|
|
|
printf "dir1/modified\0"
|
|
|
|
printf "dir2/modified\0"
|
|
|
|
printf "new\0"
|
|
|
|
printf "dir1/new\0"
|
|
|
|
printf "dir2/new\0"
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
test_lazy_prereq UNTRACKED_CACHE '
|
|
|
|
{ git update-index --test-untracked-cache; ret=$?; } &&
|
|
|
|
test $ret -ne 1
|
|
|
|
'
|
|
|
|
|
2022-05-26 21:46:58 +00:00
|
|
|
# Test that we detect and disallow repos that are incompatible with FSMonitor.
|
|
|
|
test_expect_success 'incompatible bare repo' '
|
|
|
|
test_when_finished "rm -rf ./bare-clone actual expect" &&
|
|
|
|
git init --bare bare-clone &&
|
|
|
|
|
|
|
|
test_must_fail \
|
|
|
|
git -C ./bare-clone -c core.fsmonitor=foo \
|
|
|
|
update-index --fsmonitor 2>actual &&
|
|
|
|
grep "bare repository .* is incompatible with fsmonitor" actual &&
|
|
|
|
|
|
|
|
test_must_fail \
|
|
|
|
git -C ./bare-clone -c core.fsmonitor=true \
|
|
|
|
update-index --fsmonitor 2>actual &&
|
|
|
|
grep "bare repository .* is incompatible with fsmonitor" actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success FSMONITOR_DAEMON 'run fsmonitor-daemon in bare repo' '
|
|
|
|
test_when_finished "rm -rf ./bare-clone actual" &&
|
|
|
|
git init --bare bare-clone &&
|
|
|
|
test_must_fail git -C ./bare-clone fsmonitor--daemon run 2>actual &&
|
|
|
|
grep "bare repository .* is incompatible with fsmonitor" actual
|
|
|
|
'
|
|
|
|
|
2022-05-26 21:47:00 +00:00
|
|
|
test_expect_success MINGW,FSMONITOR_DAEMON 'run fsmonitor-daemon in virtual repo' '
|
|
|
|
test_when_finished "rm -rf ./fake-virtual-clone actual" &&
|
|
|
|
git init fake-virtual-clone &&
|
|
|
|
test_must_fail git -C ./fake-virtual-clone \
|
|
|
|
-c core.virtualfilesystem=true \
|
|
|
|
fsmonitor--daemon run 2>actual &&
|
|
|
|
grep "virtual repository .* is incompatible with fsmonitor" actual
|
|
|
|
'
|
|
|
|
|
2017-09-22 16:35:46 +00:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
: >tracked &&
|
|
|
|
: >modified &&
|
|
|
|
mkdir dir1 &&
|
|
|
|
: >dir1/tracked &&
|
|
|
|
: >dir1/modified &&
|
|
|
|
mkdir dir2 &&
|
|
|
|
: >dir2/tracked &&
|
|
|
|
: >dir2/modified &&
|
|
|
|
git -c core.fsmonitor= add . &&
|
|
|
|
git -c core.fsmonitor= commit -m initial &&
|
|
|
|
git config core.fsmonitor .git/hooks/fsmonitor-test &&
|
|
|
|
cat >.gitignore <<-\EOF
|
|
|
|
.gitignore
|
|
|
|
expect*
|
|
|
|
actual*
|
|
|
|
marker*
|
2021-07-14 13:12:39 +00:00
|
|
|
trace2*
|
2017-09-22 16:35:46 +00:00
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
# test that the fsmonitor extension is off by default
|
|
|
|
test_expect_success 'fsmonitor extension is off by default' '
|
2018-09-09 17:36:30 +00:00
|
|
|
test-tool dump-fsmonitor >actual &&
|
2017-09-22 16:35:46 +00:00
|
|
|
grep "^no fsmonitor" actual
|
|
|
|
'
|
|
|
|
|
|
|
|
# test that "update-index --fsmonitor" adds the fsmonitor extension
|
|
|
|
test_expect_success 'update-index --fsmonitor" adds the fsmonitor extension' '
|
|
|
|
git update-index --fsmonitor &&
|
2018-09-09 17:36:30 +00:00
|
|
|
test-tool dump-fsmonitor >actual &&
|
2017-09-22 16:35:46 +00:00
|
|
|
grep "^fsmonitor last update" actual
|
|
|
|
'
|
|
|
|
|
|
|
|
# test that "update-index --no-fsmonitor" removes the fsmonitor extension
|
|
|
|
test_expect_success 'update-index --no-fsmonitor" removes the fsmonitor extension' '
|
|
|
|
git update-index --no-fsmonitor &&
|
2018-09-09 17:36:30 +00:00
|
|
|
test-tool dump-fsmonitor >actual &&
|
2017-09-22 16:35:46 +00:00
|
|
|
grep "^no fsmonitor" actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
h dir1/modified
|
|
|
|
H dir1/tracked
|
|
|
|
h dir2/modified
|
|
|
|
H dir2/tracked
|
|
|
|
h modified
|
|
|
|
H tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that "update-index --fsmonitor-valid" sets the fsmonitor valid bit
|
|
|
|
test_expect_success 'update-index --fsmonitor-valid" sets the fsmonitor valid bit' '
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook fsmonitor-test<<-\EOF &&
|
2020-01-07 19:04:29 +00:00
|
|
|
printf "last_update_token\0"
|
2019-11-20 08:32:17 +00:00
|
|
|
EOF
|
2017-09-22 16:35:46 +00:00
|
|
|
git update-index --fsmonitor &&
|
|
|
|
git update-index --fsmonitor-valid dir1/modified &&
|
|
|
|
git update-index --fsmonitor-valid dir2/modified &&
|
|
|
|
git update-index --fsmonitor-valid modified &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
H dir1/modified
|
|
|
|
H dir1/tracked
|
|
|
|
H dir2/modified
|
|
|
|
H dir2/tracked
|
|
|
|
H modified
|
|
|
|
H tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that "update-index --no-fsmonitor-valid" clears the fsmonitor valid bit
|
|
|
|
test_expect_success 'update-index --no-fsmonitor-valid" clears the fsmonitor valid bit' '
|
|
|
|
git update-index --no-fsmonitor-valid dir1/modified &&
|
|
|
|
git update-index --no-fsmonitor-valid dir2/modified &&
|
|
|
|
git update-index --no-fsmonitor-valid modified &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
H dir1/modified
|
|
|
|
H dir1/tracked
|
|
|
|
H dir2/modified
|
|
|
|
H dir2/tracked
|
|
|
|
H modified
|
|
|
|
H tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that all files returned by the script get flagged as invalid
|
|
|
|
test_expect_success 'all files returned by integration script get flagged as invalid' '
|
|
|
|
write_integration_script &&
|
|
|
|
dirty_repo &&
|
|
|
|
git update-index --fsmonitor &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
H dir1/modified
|
|
|
|
h dir1/new
|
|
|
|
H dir1/tracked
|
|
|
|
H dir2/modified
|
|
|
|
h dir2/new
|
|
|
|
H dir2/tracked
|
|
|
|
H modified
|
|
|
|
h new
|
|
|
|
H tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that newly added files are marked valid
|
|
|
|
test_expect_success 'newly added files are marked valid' '
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --setup --clobber fsmonitor-test<<-\EOF &&
|
2020-01-07 19:04:29 +00:00
|
|
|
printf "last_update_token\0"
|
2019-11-20 08:32:17 +00:00
|
|
|
EOF
|
2017-09-22 16:35:46 +00:00
|
|
|
git add new &&
|
|
|
|
git add dir1/new &&
|
|
|
|
git add dir2/new &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
H dir1/modified
|
|
|
|
h dir1/new
|
|
|
|
h dir1/tracked
|
|
|
|
H dir2/modified
|
|
|
|
h dir2/new
|
|
|
|
h dir2/tracked
|
|
|
|
H modified
|
|
|
|
h new
|
|
|
|
h tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that all unmodified files get marked valid
|
|
|
|
test_expect_success 'all unmodified files get marked valid' '
|
|
|
|
# modified files result in update-index returning 1
|
|
|
|
test_must_fail git update-index --refresh --force-write-index &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
H dir1/modified
|
|
|
|
h dir1/tracked
|
|
|
|
h dir2/modified
|
|
|
|
h dir2/tracked
|
|
|
|
h modified
|
|
|
|
h tracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# test that *only* files returned by the integration script get flagged as invalid
|
|
|
|
test_expect_success '*only* files returned by the integration script get flagged as invalid' '
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test<<-\EOF &&
|
2020-01-07 19:04:29 +00:00
|
|
|
printf "last_update_token\0"
|
2017-09-22 16:35:46 +00:00
|
|
|
printf "dir1/modified\0"
|
|
|
|
EOF
|
|
|
|
clean_repo &&
|
|
|
|
git update-index --refresh --force-write-index &&
|
|
|
|
echo 1 >modified &&
|
|
|
|
echo 2 >dir1/modified &&
|
|
|
|
echo 3 >dir2/modified &&
|
|
|
|
test_must_fail git update-index --refresh --force-write-index &&
|
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
# 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' '
|
|
|
|
clean_repo &&
|
|
|
|
dirty_repo &&
|
2019-11-20 08:32:17 +00:00
|
|
|
write_integration_script &&
|
2017-09-22 16:35:46 +00:00
|
|
|
git add . &&
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test<<-\EOF &&
|
2019-11-20 08:32:17 +00:00
|
|
|
EOF
|
2017-09-22 16:35:46 +00:00
|
|
|
git commit -m "to reset" &&
|
|
|
|
git reset HEAD~1 &&
|
|
|
|
git status >actual &&
|
|
|
|
git -c core.fsmonitor= status >expect &&
|
2021-02-11 01:53:53 +00:00
|
|
|
test_cmp expect actual
|
2017-09-22 16:35:46 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
# test fsmonitor with and without preloadIndex
|
|
|
|
preload_values="false true"
|
|
|
|
for preload_val in $preload_values
|
|
|
|
do
|
|
|
|
test_expect_success "setup preloadIndex to $preload_val" '
|
|
|
|
git config core.preloadIndex $preload_val &&
|
|
|
|
if test $preload_val = true
|
|
|
|
then
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
GIT_TEST_PRELOAD_INDEX=$preload_val && export GIT_TEST_PRELOAD_INDEX
|
2017-09-22 16:35:46 +00:00
|
|
|
else
|
2018-09-18 23:29:37 +00:00
|
|
|
sane_unset GIT_TEST_PRELOAD_INDEX
|
2017-09-22 16:35:46 +00:00
|
|
|
fi
|
|
|
|
'
|
|
|
|
|
|
|
|
# test fsmonitor with and without the untracked cache (if available)
|
|
|
|
uc_values="false"
|
|
|
|
test_have_prereq UNTRACKED_CACHE && uc_values="false true"
|
|
|
|
for uc_val in $uc_values
|
|
|
|
do
|
|
|
|
test_expect_success "setup untracked cache to $uc_val" '
|
|
|
|
git config core.untrackedcache $uc_val
|
|
|
|
'
|
|
|
|
|
|
|
|
# Status is well tested elsewhere so we'll just ensure that the results are
|
|
|
|
# the same when using core.fsmonitor.
|
|
|
|
test_expect_success 'compare status with and without fsmonitor' '
|
|
|
|
write_integration_script &&
|
|
|
|
clean_repo &&
|
|
|
|
dirty_repo &&
|
|
|
|
git add new &&
|
|
|
|
git add dir1/new &&
|
|
|
|
git add dir2/new &&
|
|
|
|
git status >actual &&
|
|
|
|
git -c core.fsmonitor= status >expect &&
|
2021-02-11 01:53:53 +00:00
|
|
|
test_cmp expect actual
|
2017-09-22 16:35:46 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
# Make sure it's actually skipping the check for modified and untracked
|
|
|
|
# (if enabled) files unless it is told about them.
|
|
|
|
test_expect_success "status doesn't detect unreported modifications" '
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test<<-\EOF &&
|
2020-01-07 19:04:29 +00:00
|
|
|
printf "last_update_token\0"
|
2017-09-22 16:35:46 +00:00
|
|
|
:>marker
|
|
|
|
EOF
|
|
|
|
clean_repo &&
|
|
|
|
git status &&
|
|
|
|
test_path_is_file marker &&
|
|
|
|
dirty_repo &&
|
|
|
|
rm -f marker &&
|
|
|
|
git status >actual &&
|
|
|
|
test_path_is_file marker &&
|
2023-10-31 05:23:30 +00:00
|
|
|
test_grep ! "Changes not staged for commit:" actual &&
|
2017-09-22 16:35:46 +00:00
|
|
|
if test $uc_val = true
|
|
|
|
then
|
2023-10-31 05:23:30 +00:00
|
|
|
test_grep ! "Untracked files:" actual
|
2017-09-22 16:35:46 +00:00
|
|
|
fi &&
|
|
|
|
if test $uc_val = false
|
|
|
|
then
|
2023-10-31 05:23:30 +00:00
|
|
|
test_grep "Untracked files:" actual
|
2017-09-22 16:35:46 +00:00
|
|
|
fi &&
|
|
|
|
rm -f marker
|
|
|
|
'
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2019-11-05 17:07:24 +00:00
|
|
|
# test that splitting the index doesn't interfere
|
2017-11-09 19:58:10 +00:00
|
|
|
test_expect_success 'splitting the index results in the same state' '
|
|
|
|
write_integration_script &&
|
|
|
|
dirty_repo &&
|
|
|
|
git update-index --fsmonitor &&
|
|
|
|
git ls-files -f >expect &&
|
2018-09-09 17:36:30 +00:00
|
|
|
test-tool dump-fsmonitor >&2 && echo &&
|
2017-11-09 19:58:10 +00:00
|
|
|
git update-index --fsmonitor --split-index &&
|
2018-09-09 17:36:30 +00:00
|
|
|
test-tool dump-fsmonitor >&2 && echo &&
|
2017-11-09 19:58:10 +00:00
|
|
|
git ls-files -f >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' '
|
|
|
|
test_create_repo dot-git &&
|
|
|
|
(
|
|
|
|
cd dot-git &&
|
|
|
|
: >tracked &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 tracked &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
: >modified &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 modified &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
mkdir dir1 &&
|
|
|
|
: >dir1/tracked &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 dir1/tracked &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
: >dir1/modified &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 dir1/modified &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
mkdir dir2 &&
|
|
|
|
: >dir2/tracked &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 dir2/tracked &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
: >dir2/modified &&
|
2022-02-27 21:56:59 +00:00
|
|
|
test-tool chmtime =-60 dir2/modified &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
write_integration_script &&
|
|
|
|
git config core.fsmonitor .git/hooks/fsmonitor-test &&
|
|
|
|
git update-index --untracked-cache &&
|
|
|
|
git update-index --fsmonitor &&
|
2022-02-27 21:57:00 +00:00
|
|
|
git status &&
|
2021-05-12 17:28:14 +00:00
|
|
|
GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace-before" \
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
git status &&
|
2018-09-09 17:36:27 +00:00
|
|
|
test-tool dump-untracked-cache >../before
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
) &&
|
|
|
|
cat >>dot-git/.git/hooks/fsmonitor-test <<-\EOF &&
|
|
|
|
printf ".git\0"
|
|
|
|
printf ".git/index\0"
|
|
|
|
printf "dir1/.git\0"
|
|
|
|
printf "dir1/.git/index\0"
|
|
|
|
EOF
|
|
|
|
(
|
|
|
|
cd dot-git &&
|
2021-05-12 17:28:14 +00:00
|
|
|
GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace-after" \
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
git status &&
|
2018-09-09 17:36:27 +00:00
|
|
|
test-tool dump-untracked-cache >../after
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
) &&
|
2021-05-12 17:28:14 +00:00
|
|
|
grep "directory-invalidation" trace-before | cut -d"|" -f 9 >>before &&
|
|
|
|
grep "directory-invalidation" trace-after | cut -d"|" -f 9 >>after &&
|
dir.c: ignore paths containing .git when invalidating untracked cache
read_directory() code ignores all paths named ".git" even if it's not
a valid git repository. See treat_path() for details. Since ".git" is
basically invisible to read_directory(), when we are asked to
invalidate a path that contains ".git", we can safely ignore it
because the slow path would not consider it anyway.
This helps when fsmonitor is used and we have a real ".git" repo at
worktree top. Occasionally .git/index will be updated and if the
fsmonitor hook does not filter it, untracked cache is asked to
invalidate the path ".git/index".
Without this patch, we invalidate the root directory unncessarily,
which:
- makes read_directory() fall back to slow path for root directory
(slower)
- makes the index dirty (because UNTR extension is updated). Depending
on the index size, writing it down could also be slow.
A note about the new "safe_path" knob. Since this new check could be
relatively expensive, avoid it when we know it's not needed. If the
path comes from the index, it can't contain ".git". If it does
contain, we may be screwed up at many more levels, not just this one.
Noticed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-02-07 09:21:40 +00:00
|
|
|
# UNTR extension unchanged, dir invalidation count unchanged
|
|
|
|
test_cmp before after
|
|
|
|
'
|
|
|
|
|
2019-05-07 11:10:21 +00:00
|
|
|
test_expect_success 'discard_index() also discards fsmonitor info' '
|
fsmonitor: demonstrate that it is not refreshed after discard_index()
This one is tricky.
When `core.fsmonitor` is set, a `refresh_index()` will not perform a
full scan of files that might be modified, but will query the fsmonitor
and refresh only the ones that have been actually touched.
Due to implementation details, the fsmonitor is queried in
`refresh_cache_ent()`, but of course it only has to be queried once, so
we set a flag when we did that. But when the index was discarded, we did
not re-set that flag.
So far, this is only covered by our test suite when running with
GIT_TEST_FSMONITOR=$PWD/t7519/fsmonitor-all, and only due to the way the
built-in stash interacts with the recursive merge machinery.
Let's introduce a straight-forward regression test for this.
We simply extend the "read & discard index" loop in `test-tool
read-cache` to optionally refresh the index, report on a given file's
status, and then modify that file. Due to the bug described above, only
the first refresh will actually query the fsmonitor; subsequent loop
iterations will not.
This problem was reported by Ævar Arnfjörð Bjarmason.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-05-07 11:10:20 +00:00
|
|
|
test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
|
|
|
|
test_might_fail git update-index --refresh &&
|
|
|
|
test-tool read-cache --print-and-refresh=tracked 2 >actual &&
|
|
|
|
printf "tracked is%s up to date\n" "" " not" >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2019-10-16 19:35:47 +00:00
|
|
|
# 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' '
|
2019-10-11 20:11:23 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2021-07-14 13:12:39 +00:00
|
|
|
# Usage:
|
|
|
|
# check_sparse_index_behavior [!]
|
|
|
|
# If "!" is supplied, then we verify that we do not call ensure_full_index
|
|
|
|
# during a call to 'git status'. Otherwise, we verify that we _do_ call it.
|
|
|
|
check_sparse_index_behavior () {
|
2021-09-08 01:42:25 +00:00
|
|
|
git -C full status --porcelain=v2 >expect &&
|
2021-11-29 13:47:46 +00:00
|
|
|
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
|
2021-09-08 01:42:25 +00:00
|
|
|
git -C sparse status --porcelain=v2 >actual &&
|
2021-07-14 13:12:39 +00:00
|
|
|
test_region $1 index ensure_full_index trace2.txt &&
|
|
|
|
test_region fsm_hook query trace2.txt &&
|
|
|
|
test_cmp expect actual &&
|
2021-09-08 01:42:25 +00:00
|
|
|
rm trace2.txt
|
2021-07-14 13:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success 'status succeeds with sparse index' '
|
tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
The sparse index and split index features are said to be currently
incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might
interfere with the test cases exercising the sparse index feature.
Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the
whole of 't1092-sparse-checkout-compatibility.sh'. There are,
however, two other test cases exercising sparse index, namely
'sparse-index enabled and disabled' in
't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse
index' in 't7519-status-fsmonitor.sh', and these two could fail with
GIT_TEST_SPLIT_INDEX=1 as well [2].
Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two
test cases to avoid such interference.
Note that this is the minimal change to merely avoid failures when
these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly,
though, without these changes the 'git sparse-checkout init --cone
--sparse-index' commands still succeed even with split index, and set
all the necessary configuration variables and create the initial
'$GIT_DIR/info/sparse-checkout' file, but the test failures are caused
by later sanity checks finding that the index is not in fact a sparse
index. This indicates that 'git sparse-checkout init --sparse-index'
lacks some error checking and its tests lack coverage related to split
index, but fixing those issues is beyond the scope of this patch
series.
[1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/
[2] Neither of these test cases fail at the moment, because
GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and
it broke long before the sparse index feature was added.
This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then
both test cases mentioned above would fail.
(The diff is best viewed with '--ignore-all-space')
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-26 21:00:03 +00:00
|
|
|
(
|
|
|
|
sane_unset GIT_TEST_SPLIT_INDEX &&
|
2021-07-14 13:12:39 +00:00
|
|
|
|
tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
The sparse index and split index features are said to be currently
incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might
interfere with the test cases exercising the sparse index feature.
Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the
whole of 't1092-sparse-checkout-compatibility.sh'. There are,
however, two other test cases exercising sparse index, namely
'sparse-index enabled and disabled' in
't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse
index' in 't7519-status-fsmonitor.sh', and these two could fail with
GIT_TEST_SPLIT_INDEX=1 as well [2].
Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two
test cases to avoid such interference.
Note that this is the minimal change to merely avoid failures when
these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly,
though, without these changes the 'git sparse-checkout init --cone
--sparse-index' commands still succeed even with split index, and set
all the necessary configuration variables and create the initial
'$GIT_DIR/info/sparse-checkout' file, but the test failures are caused
by later sanity checks finding that the index is not in fact a sparse
index. This indicates that 'git sparse-checkout init --sparse-index'
lacks some error checking and its tests lack coverage related to split
index, but fixing those issues is beyond the scope of this patch
series.
[1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/
[2] Neither of these test cases fail at the moment, because
GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and
it broke long before the sparse index feature was added.
This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then
both test cases mentioned above would fail.
(The diff is best viewed with '--ignore-all-space')
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-26 21:00:03 +00:00
|
|
|
git clone . full &&
|
|
|
|
git clone --sparse . sparse &&
|
|
|
|
git -C sparse sparse-checkout init --cone --sparse-index &&
|
|
|
|
git -C sparse sparse-checkout set dir1 dir2 &&
|
2021-07-14 13:12:39 +00:00
|
|
|
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test <<-\EOF &&
|
tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
The sparse index and split index features are said to be currently
incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might
interfere with the test cases exercising the sparse index feature.
Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the
whole of 't1092-sparse-checkout-compatibility.sh'. There are,
however, two other test cases exercising sparse index, namely
'sparse-index enabled and disabled' in
't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse
index' in 't7519-status-fsmonitor.sh', and these two could fail with
GIT_TEST_SPLIT_INDEX=1 as well [2].
Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two
test cases to avoid such interference.
Note that this is the minimal change to merely avoid failures when
these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly,
though, without these changes the 'git sparse-checkout init --cone
--sparse-index' commands still succeed even with split index, and set
all the necessary configuration variables and create the initial
'$GIT_DIR/info/sparse-checkout' file, but the test failures are caused
by later sanity checks finding that the index is not in fact a sparse
index. This indicates that 'git sparse-checkout init --sparse-index'
lacks some error checking and its tests lack coverage related to split
index, but fixing those issues is beyond the scope of this patch
series.
[1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/
[2] Neither of these test cases fail at the moment, because
GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and
it broke long before the sparse index feature was added.
This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then
both test cases mentioned above would fail.
(The diff is best viewed with '--ignore-all-space')
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-26 21:00:03 +00:00
|
|
|
printf "last_update_token\0"
|
|
|
|
EOF
|
|
|
|
git -C full config core.fsmonitor ../.git/hooks/fsmonitor-test &&
|
|
|
|
git -C sparse config core.fsmonitor ../.git/hooks/fsmonitor-test &&
|
|
|
|
check_sparse_index_behavior ! &&
|
2021-09-08 01:42:25 +00:00
|
|
|
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test <<-\EOF &&
|
tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
The sparse index and split index features are said to be currently
incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might
interfere with the test cases exercising the sparse index feature.
Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the
whole of 't1092-sparse-checkout-compatibility.sh'. There are,
however, two other test cases exercising sparse index, namely
'sparse-index enabled and disabled' in
't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse
index' in 't7519-status-fsmonitor.sh', and these two could fail with
GIT_TEST_SPLIT_INDEX=1 as well [2].
Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two
test cases to avoid such interference.
Note that this is the minimal change to merely avoid failures when
these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly,
though, without these changes the 'git sparse-checkout init --cone
--sparse-index' commands still succeed even with split index, and set
all the necessary configuration variables and create the initial
'$GIT_DIR/info/sparse-checkout' file, but the test failures are caused
by later sanity checks finding that the index is not in fact a sparse
index. This indicates that 'git sparse-checkout init --sparse-index'
lacks some error checking and its tests lack coverage related to split
index, but fixing those issues is beyond the scope of this patch
series.
[1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/
[2] Neither of these test cases fail at the moment, because
GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and
it broke long before the sparse index feature was added.
This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then
both test cases mentioned above would fail.
(The diff is best viewed with '--ignore-all-space')
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-26 21:00:03 +00:00
|
|
|
printf "last_update_token\0"
|
|
|
|
printf "dir1/modified\0"
|
|
|
|
EOF
|
|
|
|
check_sparse_index_behavior ! &&
|
|
|
|
|
|
|
|
git -C sparse sparse-checkout add dir1a &&
|
|
|
|
|
|
|
|
for repo in full sparse
|
|
|
|
do
|
|
|
|
cp -r $repo/dir1 $repo/dir1a &&
|
|
|
|
git -C $repo add dir1a &&
|
|
|
|
git -C $repo commit -m "add dir1a" || return 1
|
|
|
|
done &&
|
|
|
|
git -C sparse sparse-checkout set dir1 dir2 &&
|
|
|
|
|
|
|
|
# This one modifies outside the sparse-checkout definition
|
|
|
|
# and hence we expect to expand the sparse-index.
|
2022-03-17 10:13:06 +00:00
|
|
|
test_hook --clobber fsmonitor-test <<-\EOF &&
|
tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
The sparse index and split index features are said to be currently
incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might
interfere with the test cases exercising the sparse index feature.
Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the
whole of 't1092-sparse-checkout-compatibility.sh'. There are,
however, two other test cases exercising sparse index, namely
'sparse-index enabled and disabled' in
't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse
index' in 't7519-status-fsmonitor.sh', and these two could fail with
GIT_TEST_SPLIT_INDEX=1 as well [2].
Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two
test cases to avoid such interference.
Note that this is the minimal change to merely avoid failures when
these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly,
though, without these changes the 'git sparse-checkout init --cone
--sparse-index' commands still succeed even with split index, and set
all the necessary configuration variables and create the initial
'$GIT_DIR/info/sparse-checkout' file, but the test failures are caused
by later sanity checks finding that the index is not in fact a sparse
index. This indicates that 'git sparse-checkout init --sparse-index'
lacks some error checking and its tests lack coverage related to split
index, but fixing those issues is beyond the scope of this patch
series.
[1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/
[2] Neither of these test cases fail at the moment, because
GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and
it broke long before the sparse index feature was added.
This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then
both test cases mentioned above would fail.
(The diff is best viewed with '--ignore-all-space')
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-26 21:00:03 +00:00
|
|
|
printf "last_update_token\0"
|
|
|
|
printf "dir1a/modified\0"
|
|
|
|
EOF
|
|
|
|
check_sparse_index_behavior
|
|
|
|
)
|
2021-07-14 13:12:39 +00:00
|
|
|
'
|
|
|
|
|
2017-09-22 16:35:46 +00:00
|
|
|
test_done
|