summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sparse-index.c1
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh17
2 files changed, 18 insertions, 0 deletions
diff --git a/sparse-index.c b/sparse-index.c
index 619ff7c2e2..7631f7bd00 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -52,6 +52,7 @@ static int convert_to_sparse_rec(struct index_state *istate,
struct cache_entry *ce = istate->cache[i];
if (ce_stage(ce) ||
+ S_ISGITLINK(ce->ce_mode) ||
!(ce->ce_flags & CE_SKIP_WORKTREE))
can_convert = 0;
}
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 1e888d1951..cba5f89b1e 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -376,4 +376,21 @@ test_expect_success 'clean' '
test_sparse_match test_path_is_dir folder1
'
+test_expect_success 'submodule handling' '
+ init_repos &&
+
+ test_all_match mkdir modules &&
+ test_all_match touch modules/a &&
+ test_all_match git add modules &&
+ test_all_match git commit -m "add modules directory" &&
+
+ run_on_all git submodule add "$(pwd)/initial-repo" modules/sub &&
+ test_all_match git commit -m "add submodule" &&
+
+ # having a submodule prevents "modules" from collapse
+ test-tool -C sparse-index read-cache --table >cache &&
+ grep "100644 blob .* modules/a" cache &&
+ grep "160000 commit $(git -C initial-repo rev-parse HEAD) modules/sub" cache
+'
+
test_done