Skip to content

Commit 331bb7d

Browse files
committed
sparse-checkout: document interactions with submodules
Junio asked what the behavior is between the sparse-checkout feature and the submodule feature. The sparse-checkout builtin has not changed the way these features interact, but we may as well document it in the builtin docs. Using 'git submodule (init|deinit)' a user can select a subset of submodules to populate. This behaves very similar to the sparse-checkout feature, but those directories contain their own .git directory including an object database and ref space. To have the sparse-checkout file also determine if those files should exist would easily cause problems. Therefore, keeping these features independent in this way is the best way forward. Also create a test that demonstrates this behavior to make sure it doesn't change as the sparse-checkout feature evolves. Reported-by: Junio C Hamano <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent d6f4f40 commit 331bb7d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Documentation/git-sparse-checkout.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ case-insensitive check. This corrects for case mismatched filenames in the
164164
'git sparse-checkout set' command to reflect the expected cone in the working
165165
directory.
166166

167+
168+
SUBMODULES
169+
----------
170+
171+
If your repository contains one or more submodules, then those submodules will
172+
appear based on which you initialized with the `git submodule` command. If
173+
your sparse-checkout patterns exclude an initialized submodule, then that
174+
submodule will still appear in your working directory.
175+
176+
167177
SEE ALSO
168178
--------
169179

t/t1091-sparse-checkout-builtin.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,32 @@ test_expect_success 'cone mode: set with core.ignoreCase=true' '
340340
test_cmp expect dir
341341
'
342342

343+
test_expect_success 'interaction with submodules' '
344+
git clone repo super &&
345+
(
346+
cd super &&
347+
mkdir modules &&
348+
git submodule add ../repo modules/child &&
349+
git add . &&
350+
git commit -m "add submodule" &&
351+
git sparse-checkout init --cone &&
352+
git sparse-checkout set folder1
353+
) &&
354+
list_files super >dir &&
355+
cat >expect <<-EOF &&
356+
a
357+
folder1
358+
modules
359+
EOF
360+
test_cmp expect dir &&
361+
list_files super/modules/child >dir &&
362+
cat >expect <<-EOF &&
363+
a
364+
deep
365+
folder1
366+
folder2
367+
EOF
368+
test_cmp expect dir
369+
'
370+
343371
test_done

0 commit comments

Comments
 (0)