summaryrefslogtreecommitdiff
path: root/t/t1092-sparse-checkout-compatibility.sh
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2022-04-26 20:43:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-26 20:56:38 (GMT)
commita37d14422a4edd4f95abbe9532f518127cd3ef69 (patch)
treec083f3354ae9913829e7a3e1e350f985cb081f05 /t/t1092-sparse-checkout-compatibility.sh
parenta9e0a49dc427a8c442619e7937abeb1af1f35ff2 (diff)
downloadgit-a37d14422a4edd4f95abbe9532f518127cd3ef69.zip
git-a37d14422a4edd4f95abbe9532f518127cd3ef69.tar.gz
git-a37d14422a4edd4f95abbe9532f518127cd3ef69.tar.bz2
show: integrate with the sparse index
The 'git show' command can take an input to request the state of an object in the index. This can lead to parsing the index in order to load a specific file entry. Without the change presented here, a sparse index would expand to a full one, taking much longer than usual to access a simple file. There is one behavioral change that happens here, though: we now can find a sparse directory entry within the index! Commands that previously failed because we could not find an entry in the worktree or index now succeed because we _do_ find an entry in the index. There might be more work to do to make other situations succeed when looking for an indexed tree, perhaps by looking at or updating the cache-tree extension as needed. These situations include having a full index or asking for a directory that is within the sparse-checkout cone (and hence is not a sparse directory entry in the index). For now, we demonstrate how the sparse index integration is extremely simple for files outside of the cone as well as directories within the cone. A later change will resolve this behavior around sparse directories. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1092-sparse-checkout-compatibility.sh')
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh24
1 files changed, 20 insertions, 4 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 74792b5..3506c02 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -1159,12 +1159,21 @@ test_expect_success 'show (cached blobs/trees)' '
test_sparse_match git show :folder1/a &&
# Asking "git show" for directories in the index
- # does not work as implemented. The error message is
- # different for a full checkout and a sparse checkout
- # when the directory is outside of the cone.
+ # had different behavior depending on the existence
+ # of a sparse index.
test_all_match test_must_fail git show :deep/ &&
test_must_fail git -C full-checkout show :folder1/ &&
- test_sparse_match test_must_fail git show :folder1/
+ test_must_fail git -C sparse-checkout show :folder1/ &&
+
+ git -C sparse-index show :folder1/ >actual &&
+ git -C full-checkout show HEAD:folder1 >expect &&
+
+ # The output of "git show" includes the way we referenced the
+ # objects, so strip that out.
+ test_line_count = 4 actual &&
+ tail -n 2 actual >actual-trunc &&
+ tail -n 2 expect >expect-trunc &&
+ test_cmp expect-trunc actual-trunc
'
test_expect_success 'submodule handling' '
@@ -1388,6 +1397,13 @@ test_expect_success 'sparse index is not expanded: diff' '
ensure_not_expanded diff --cached
'
+test_expect_success 'sparse index is not expanded: show' '
+ init_repos &&
+
+ ensure_not_expanded show :a &&
+ ensure_not_expanded show :deep/a
+'
+
test_expect_success 'sparse index is not expanded: update-index' '
init_repos &&