summaryrefslogtreecommitdiff
path: root/t/t1091-sparse-checkout-builtin.sh
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2019-11-21 22:04:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-22 07:11:43 (GMT)
commitd89f09c8289a764f0a974e02bd5b38cf60d1a7d7 (patch)
treecd5b449c3ac6924fa91fd8a3380018b2ed622faf /t/t1091-sparse-checkout-builtin.sh
parentbab3c3590879c5680060a5d5e2b93b4f97519025 (diff)
downloadgit-d89f09c8289a764f0a974e02bd5b38cf60d1a7d7.zip
git-d89f09c8289a764f0a974e02bd5b38cf60d1a7d7.tar.gz
git-d89f09c8289a764f0a974e02bd5b38cf60d1a7d7.tar.bz2
clone: add --sparse mode
When someone wants to clone a large repository, but plans to work using a sparse-checkout file, they either need to do a full checkout first and then reduce the patterns they included, or clone with --no-checkout, set up their patterns, and then run a checkout manually. This requires knowing a lot about the repo shape and how sparse-checkout works. Add a new '--sparse' option to 'git clone' that initializes the sparse-checkout file to include the following patterns: /* !/*/ These patterns include every file in the root directory, but no directories. This allows a repo to include files like a README or a bootstrapping script to grow enlistments from that point. During the 'git sparse-checkout init' call, we must first look to see if HEAD is valid, since 'git clone' does not have a valid HEAD at the point where it initializes the sparse-checkout. The following checkout within the clone command will create the HEAD ref and update the working directory correctly. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1091-sparse-checkout-builtin.sh')
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index 21143c5..78c20cb 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -82,4 +82,17 @@ test_expect_success 'init with existing sparse-checkout' '
test_cmp expect dir
'
+test_expect_success 'clone --sparse' '
+ git clone --sparse repo clone &&
+ git -C clone sparse-checkout list >actual &&
+ cat >expect <<-EOF &&
+ /*
+ !/*/
+ EOF
+ test_cmp expect actual &&
+ ls clone >dir &&
+ echo a >expect &&
+ test_cmp expect dir
+'
+
test_done