Skip to content

Commit

Permalink
t1092: add deeper changes during a checkout
Browse files Browse the repository at this point in the history
Extend the repository data in the setup of t1092 to include more
directories within two parent directories. This reproduces a bug found
by users of the sparse index feature with suitably-complicated
sparse-checkout definitions.

Add a failing test that fails in its first 'git checkout deepest' run in
the sparse index case with this error:

  error: Your local changes to the following files would be overwritten by checkout:
          deep/deeper1/deepest2/a
          deep/deeper1/deepest3/a
  Please commit your changes or stash them before you switch branches.
  Aborting

The next change will fix this error, and that fix will make it clear why
the extra depth is necessary for revealing this bug. The assignment of
the sparse-checkout definition to include deep/deeper1/deepest as a
sibling directory is important to ensure that deep/deeper1 is not a
sparse directory entry, but deep/deeper1/deepest2 is.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Dec 4, 2021
1 parent 599a56a commit 10b29a0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion t/t1092-sparse-checkout-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test_expect_success 'setup' '
mkdir folder1 folder2 deep x &&
mkdir deep/deeper1 deep/deeper2 deep/before deep/later &&
mkdir deep/deeper1/deepest &&
mkdir deep/deeper1/deepest2 &&
mkdir deep/deeper1/deepest3 &&
echo "after deeper1" >deep/e &&
echo "after deepest" >deep/deeper1/e &&
cp a folder1 &&
Expand All @@ -30,7 +32,9 @@ test_expect_success 'setup' '
cp a deep/deeper2 &&
cp a deep/later &&
cp a deep/deeper1/deepest &&
cp -r deep/deeper1/deepest deep/deeper2 &&
cp a deep/deeper1/deepest2 &&
cp a deep/deeper1/deepest3 &&
cp -r deep/deeper1/ deep/deeper2 &&
mkdir deep/deeper1/0 &&
mkdir deep/deeper1/0/0 &&
touch deep/deeper1/0/1 &&
Expand Down Expand Up @@ -126,6 +130,8 @@ test_expect_success 'setup' '
git checkout -b deepest base &&
echo "updated deepest" >deep/deeper1/deepest/a &&
echo "updated deepest2" >deep/deeper1/deepest2/a &&
echo "updated deepest3" >deep/deeper1/deepest3/a &&
git commit -a -m "update deepest" &&
git checkout -f base &&
Expand Down Expand Up @@ -302,6 +308,14 @@ test_expect_success 'add, commit, checkout' '
test_all_match git checkout -
'

test_expect_failure 'deep changes during checkout' '
init_repos &&
test_sparse_match git sparse-checkout set deep/deeper1/deepest &&
test_all_match git checkout deepest &&
test_all_match git checkout base
'

test_expect_success 'add outside sparse cone' '
init_repos &&
Expand Down

0 comments on commit 10b29a0

Please sign in to comment.