2021-01-23 20:58:19 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='compare full workdir to sparse workdir'
|
|
|
|
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
# The verify_cache_tree() check is not sparse-aware (yet).
|
|
|
|
# So, disable the check until that integration is complete.
|
|
|
|
GIT_TEST_CHECK_CACHE_TREE=0
|
|
|
|
GIT_TEST_SPLIT_INDEX=0
|
|
|
|
|
2021-01-23 20:58:19 +01:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
git init initial-repo &&
|
|
|
|
(
|
2021-03-30 15:10:49 +02:00
|
|
|
GIT_TEST_SPARSE_INDEX=0 &&
|
2021-01-23 20:58:19 +01:00
|
|
|
cd initial-repo &&
|
|
|
|
echo a >a &&
|
|
|
|
echo "after deep" >e &&
|
|
|
|
echo "after folder1" >g &&
|
|
|
|
echo "after x" >z &&
|
|
|
|
mkdir folder1 folder2 deep x &&
|
|
|
|
mkdir deep/deeper1 deep/deeper2 &&
|
|
|
|
mkdir deep/deeper1/deepest &&
|
|
|
|
echo "after deeper1" >deep/e &&
|
|
|
|
echo "after deepest" >deep/deeper1/e &&
|
|
|
|
cp a folder1 &&
|
|
|
|
cp a folder2 &&
|
|
|
|
cp a x &&
|
|
|
|
cp a deep &&
|
|
|
|
cp a deep/deeper1 &&
|
|
|
|
cp a deep/deeper2 &&
|
|
|
|
cp a deep/deeper1/deepest &&
|
|
|
|
cp -r deep/deeper1/deepest deep/deeper2 &&
|
|
|
|
git add . &&
|
|
|
|
git commit -m "initial commit" &&
|
|
|
|
git checkout -b base &&
|
|
|
|
for dir in folder1 folder2 deep
|
|
|
|
do
|
|
|
|
git checkout -b update-$dir &&
|
|
|
|
echo "updated $dir" >$dir/a &&
|
|
|
|
git commit -a -m "update $dir" || return 1
|
|
|
|
done &&
|
|
|
|
|
|
|
|
git checkout -b rename-base base &&
|
|
|
|
echo >folder1/larger-content <<-\EOF &&
|
|
|
|
matching
|
|
|
|
lines
|
|
|
|
help
|
|
|
|
inexact
|
|
|
|
renames
|
|
|
|
EOF
|
|
|
|
cp folder1/larger-content folder2/ &&
|
|
|
|
cp folder1/larger-content deep/deeper1/ &&
|
|
|
|
git add . &&
|
|
|
|
git commit -m "add interesting rename content" &&
|
|
|
|
|
|
|
|
git checkout -b rename-out-to-out rename-base &&
|
|
|
|
mv folder1/a folder2/b &&
|
|
|
|
mv folder1/larger-content folder2/edited-content &&
|
|
|
|
echo >>folder2/edited-content &&
|
|
|
|
git add . &&
|
|
|
|
git commit -m "rename folder1/... to folder2/..." &&
|
|
|
|
|
|
|
|
git checkout -b rename-out-to-in rename-base &&
|
|
|
|
mv folder1/a deep/deeper1/b &&
|
|
|
|
mv folder1/larger-content deep/deeper1/edited-content &&
|
|
|
|
echo >>deep/deeper1/edited-content &&
|
|
|
|
git add . &&
|
|
|
|
git commit -m "rename folder1/... to deep/deeper1/..." &&
|
|
|
|
|
|
|
|
git checkout -b rename-in-to-out rename-base &&
|
|
|
|
mv deep/deeper1/a folder1/b &&
|
|
|
|
mv deep/deeper1/larger-content folder1/edited-content &&
|
|
|
|
echo >>folder1/edited-content &&
|
|
|
|
git add . &&
|
|
|
|
git commit -m "rename deep/deeper1/... to folder1/..." &&
|
|
|
|
|
|
|
|
git checkout -b deepest base &&
|
|
|
|
echo "updated deepest" >deep/deeper1/deepest/a &&
|
|
|
|
git commit -a -m "update deepest" &&
|
|
|
|
|
|
|
|
git checkout -f base &&
|
|
|
|
git reset --hard
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
init_repos () {
|
|
|
|
rm -rf full-checkout sparse-checkout sparse-index &&
|
|
|
|
|
|
|
|
# create repos in initial state
|
|
|
|
cp -r initial-repo full-checkout &&
|
|
|
|
git -C full-checkout reset --hard &&
|
|
|
|
|
|
|
|
cp -r initial-repo sparse-checkout &&
|
|
|
|
git -C sparse-checkout reset --hard &&
|
2021-03-30 15:10:49 +02:00
|
|
|
|
|
|
|
cp -r initial-repo sparse-index &&
|
|
|
|
git -C sparse-index reset --hard &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
# initialize sparse-checkout definitions
|
2021-03-30 15:10:49 +02:00
|
|
|
git -C sparse-checkout sparse-checkout init --cone &&
|
|
|
|
git -C sparse-checkout sparse-checkout set deep &&
|
|
|
|
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout init --cone &&
|
|
|
|
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep
|
2021-01-23 20:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run_on_sparse () {
|
|
|
|
(
|
|
|
|
cd sparse-checkout &&
|
2021-03-30 15:10:49 +02:00
|
|
|
GIT_TEST_SPARSE_INDEX=0 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd sparse-index &&
|
|
|
|
GIT_TEST_SPARSE_INDEX=1 "$@" >../sparse-index-out 2>../sparse-index-err
|
2021-01-23 20:58:19 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
run_on_all () {
|
|
|
|
(
|
|
|
|
cd full-checkout &&
|
2021-03-30 15:10:49 +02:00
|
|
|
GIT_TEST_SPARSE_INDEX=0 "$@" >../full-checkout-out 2>../full-checkout-err
|
2021-01-23 20:58:19 +01:00
|
|
|
) &&
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_sparse "$@"
|
2021-01-23 20:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
test_all_match () {
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all "$@" &&
|
2021-01-23 20:58:19 +01:00
|
|
|
test_cmp full-checkout-out sparse-checkout-out &&
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_cmp full-checkout-out sparse-index-out &&
|
|
|
|
test_cmp full-checkout-err sparse-checkout-err &&
|
|
|
|
test_cmp full-checkout-err sparse-index-err
|
2021-01-23 20:58:19 +01:00
|
|
|
}
|
|
|
|
|
2021-03-30 15:10:49 +02:00
|
|
|
test_sparse_match () {
|
|
|
|
run_on_sparse "$@" &&
|
|
|
|
test_cmp sparse-checkout-out sparse-index-out &&
|
|
|
|
test_cmp sparse-checkout-err sparse-index-err
|
|
|
|
}
|
|
|
|
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_expect_success 'sparse-index contents' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test-tool -C sparse-index read-cache --table >cache &&
|
|
|
|
for dir in folder1 folder2 x
|
|
|
|
do
|
|
|
|
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
|
|
|
|
grep "040000 tree $TREE $dir/" cache \
|
|
|
|
|| return 1
|
|
|
|
done &&
|
|
|
|
|
|
|
|
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set folder1 &&
|
|
|
|
|
|
|
|
test-tool -C sparse-index read-cache --table >cache &&
|
|
|
|
for dir in deep folder2 x
|
|
|
|
do
|
|
|
|
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
|
|
|
|
grep "040000 tree $TREE $dir/" cache \
|
|
|
|
|| return 1
|
|
|
|
done &&
|
|
|
|
|
|
|
|
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep/deeper1 &&
|
|
|
|
|
|
|
|
test-tool -C sparse-index read-cache --table >cache &&
|
|
|
|
for dir in deep/deeper2 folder1 folder2 x
|
|
|
|
do
|
|
|
|
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
|
|
|
|
grep "040000 tree $TREE $dir/" cache \
|
|
|
|
|| return 1
|
|
|
|
done
|
|
|
|
'
|
|
|
|
|
2021-03-30 15:10:51 +02:00
|
|
|
test_expect_success 'expanded in-memory index matches full index' '
|
|
|
|
init_repos &&
|
|
|
|
test_sparse_match test-tool read-cache --expand --table
|
|
|
|
'
|
|
|
|
|
2021-01-23 20:58:19 +01:00
|
|
|
test_expect_success 'status with options' '
|
|
|
|
init_repos &&
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_sparse_match ls &&
|
2021-01-23 20:58:19 +01:00
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git status --porcelain=v2 -z -u &&
|
|
|
|
test_all_match git status --porcelain=v2 -uno &&
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all touch README.md &&
|
2021-01-23 20:58:19 +01:00
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git status --porcelain=v2 -z -u &&
|
|
|
|
test_all_match git status --porcelain=v2 -uno &&
|
|
|
|
test_all_match git add README.md &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git status --porcelain=v2 -z -u &&
|
|
|
|
test_all_match git status --porcelain=v2 -uno
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'add, commit, checkout' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
write_script edit-contents <<-\EOF &&
|
|
|
|
echo text >>$1
|
|
|
|
EOF
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all ../edit-contents README.md &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git add README.md &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git commit -m "Add README.md" &&
|
|
|
|
|
|
|
|
test_all_match git checkout HEAD~1 &&
|
|
|
|
test_all_match git checkout - &&
|
|
|
|
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all ../edit-contents README.md &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git add -A &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git commit -m "Extend README.md" &&
|
|
|
|
|
|
|
|
test_all_match git checkout HEAD~1 &&
|
|
|
|
test_all_match git checkout - &&
|
|
|
|
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all ../edit-contents deep/newfile &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git status --porcelain=v2 -uno &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git add . &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git commit -m "add deep/newfile" &&
|
|
|
|
|
|
|
|
test_all_match git checkout HEAD~1 &&
|
|
|
|
test_all_match git checkout -
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'checkout and reset --hard' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git checkout update-folder1 &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
|
|
|
|
test_all_match git checkout update-deep &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
|
|
|
|
test_all_match git checkout -b reset-test &&
|
|
|
|
test_all_match git reset --hard deepest &&
|
|
|
|
test_all_match git reset --hard update-folder1 &&
|
|
|
|
test_all_match git reset --hard update-folder2
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff --staged' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
write_script edit-contents <<-\EOF &&
|
|
|
|
echo text >>README.md
|
|
|
|
EOF
|
2021-03-30 15:10:46 +02:00
|
|
|
run_on_all ../edit-contents &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git diff &&
|
|
|
|
test_all_match git diff --staged &&
|
|
|
|
test_all_match git add README.md &&
|
|
|
|
test_all_match git diff &&
|
|
|
|
test_all_match git diff --staged
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff with renames' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
for branch in rename-out-to-out rename-out-to-in rename-in-to-out
|
|
|
|
do
|
|
|
|
test_all_match git checkout rename-base &&
|
|
|
|
test_all_match git checkout $branch -- .&&
|
|
|
|
test_all_match git diff --staged --no-renames &&
|
|
|
|
test_all_match git diff --staged --find-renames || return 1
|
|
|
|
done
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'log with pathspec outside sparse definition' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git log -- a &&
|
|
|
|
test_all_match git log -- folder1/a &&
|
|
|
|
test_all_match git log -- folder2/a &&
|
|
|
|
test_all_match git log -- deep/a &&
|
|
|
|
test_all_match git log -- deep/deeper1/a &&
|
|
|
|
test_all_match git log -- deep/deeper1/deepest/a &&
|
|
|
|
|
|
|
|
test_all_match git checkout update-folder1 &&
|
|
|
|
test_all_match git log -- folder1/a
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'blame with pathspec inside sparse definition' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git blame a &&
|
|
|
|
test_all_match git blame deep/a &&
|
|
|
|
test_all_match git blame deep/deeper1/a &&
|
|
|
|
test_all_match git blame deep/deeper1/deepest/a
|
|
|
|
'
|
|
|
|
|
|
|
|
# TODO: blame currently does not support blaming files outside of the
|
|
|
|
# sparse definition. It complains that the file doesn't exist locally.
|
|
|
|
test_expect_failure 'blame with pathspec outside sparse definition' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git blame folder1/a &&
|
|
|
|
test_all_match git blame folder2/a &&
|
|
|
|
test_all_match git blame deep/deeper2/a &&
|
|
|
|
test_all_match git blame deep/deeper2/deepest/a
|
|
|
|
'
|
|
|
|
|
|
|
|
# TODO: reset currently does not behave as expected when in a
|
|
|
|
# sparse-checkout.
|
|
|
|
test_expect_failure 'checkout and reset (mixed)' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git checkout -b reset-test update-deep &&
|
|
|
|
test_all_match git reset deepest &&
|
|
|
|
test_all_match git reset update-folder1 &&
|
|
|
|
test_all_match git reset update-folder2
|
|
|
|
'
|
|
|
|
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
# Ensure that sparse-index behaves identically to
|
|
|
|
# sparse-checkout with a full index.
|
|
|
|
test_expect_success 'checkout and reset (mixed) [sparse]' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_sparse_match git checkout -b reset-test update-deep &&
|
|
|
|
test_sparse_match git reset deepest &&
|
|
|
|
test_sparse_match git reset update-folder1 &&
|
|
|
|
test_sparse_match git reset update-folder2
|
|
|
|
'
|
|
|
|
|
2021-01-23 20:58:19 +01:00
|
|
|
test_expect_success 'merge' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
test_all_match git checkout -b merge update-deep &&
|
|
|
|
test_all_match git merge -m "folder1" update-folder1 &&
|
|
|
|
test_all_match git rev-parse HEAD^{tree} &&
|
|
|
|
test_all_match git merge -m "folder2" update-folder2 &&
|
|
|
|
test_all_match git rev-parse HEAD^{tree}
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge with outside renames' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
for type in out-to-out out-to-in in-to-out
|
|
|
|
do
|
|
|
|
test_all_match git reset --hard &&
|
|
|
|
test_all_match git checkout -f -b merge-$type update-deep &&
|
|
|
|
test_all_match git merge -m "$type" rename-$type &&
|
|
|
|
test_all_match git rev-parse HEAD^{tree} || return 1
|
|
|
|
done
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'clean' '
|
|
|
|
init_repos &&
|
|
|
|
|
|
|
|
echo bogus >>.gitignore &&
|
|
|
|
run_on_all cp ../.gitignore . &&
|
|
|
|
test_all_match git add .gitignore &&
|
2021-03-30 15:10:46 +02:00
|
|
|
test_all_match git commit -m "ignore bogus files" &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
run_on_sparse mkdir folder1 &&
|
|
|
|
run_on_all touch folder1/bogus &&
|
|
|
|
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
|
|
|
test_all_match git clean -f &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_sparse_match ls &&
|
|
|
|
test_sparse_match ls folder1 &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git clean -xf &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_sparse_match ls &&
|
|
|
|
test_sparse_match ls folder1 &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
|
|
|
test_all_match git clean -xdf &&
|
|
|
|
test_all_match git status --porcelain=v2 &&
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_sparse_match ls &&
|
|
|
|
test_sparse_match ls folder1 &&
|
2021-01-23 20:58:19 +01:00
|
|
|
|
sparse-index: convert from full to sparse
If we have a full index, then we can convert it to a sparse index by
replacing directories outside of the sparse cone with sparse directory
entries. The convert_to_sparse() method does this, when the situation is
appropriate.
For now, we avoid converting the index to a sparse index if:
1. the index is split.
2. the index is already sparse.
3. sparse-checkout is disabled.
4. sparse-checkout does not use cone mode.
Finally, we currently limit the conversion to when the
GIT_TEST_SPARSE_INDEX environment variable is enabled. A mode using Git
config will be added in a later change.
The trickiest thing about this conversion is that we might not be able
to mark a directory as a sparse directory just because it is outside the
sparse cone. There might be unmerged files within that directory, so we
need to look for those. Also, if there is some strange reason why a file
is not marked with CE_SKIP_WORKTREE, then we should give up on
converting that directory. There is still hope that some of its
subdirectories might be able to convert to sparse, so we keep looking
deeper.
The conversion process is assisted by the cache-tree extension. This is
calculated from the full index if it does not already exist. We then
abandon the cache-tree as it no longer applies to the newly-sparse
index. Thus, this cache-tree will be recalculated in every
sparse-full-sparse round-trip until we integrate the cache-tree
extension with the sparse index.
Some Git commands use the index after writing it. For example, 'git add'
will update the index, then write it to disk, then read its entries to
report information. To keep the in-memory index in a full state after
writing, we re-expand it to a full one after the write. This is wasteful
for commands that only write the index and do not read from it again,
but that is only the case until we make those commands "sparse aware."
We can compare the behavior of the sparse-index in
t1092-sparse-checkout-compability.sh by using GIT_TEST_SPARSE_INDEX=1
when operating on the 'sparse-index' repo. We can also compare the two
sparse repos directly, such as comparing their indexes (when expanded to
full in the case of the 'sparse-index' repo). We also verify that the
index is actually populated with sparse directory entries.
The 'checkout and reset (mixed)' test is marked for failure when
comparing a sparse repo to a full repo, but we can compare the two
sparse-checkout cases directly to ensure that we are not changing the
behavior when using a sparse index.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-30 15:10:55 +02:00
|
|
|
test_sparse_match test_path_is_dir folder1
|
2021-01-23 20:58:19 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|