]> granicus.if.org Git - git/commit
clone: add --sparse mode
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 21 Oct 2019 13:56:12 +0000 (13:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Oct 2019 03:42:04 +0000 (12:42 +0900)
commit2e885711e4b70de1664244202abdc762e7c16b80
treeab4f2a5aec521893364dfa034df11d4ca1219ab5
parent7e12ce4c40afea6614e0afb6f8c281e2a259123b
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>
Documentation/git-clone.txt
builtin/clone.c
builtin/sparse-checkout.c
t/t1091-sparse-checkout-builtin.sh