]> granicus.if.org Git - git/commit
sparse-checkout: update working directory in-process
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 21 Oct 2019 13:56:24 +0000 (13:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Oct 2019 03:42:21 +0000 (12:42 +0900)
commitefd9c53b6d4a79029f5fb67be36c6a7930eaed8e
tree08ef00570bcc5ad8b8f4444e1ed869d93aebefb8
parentf9e96bf90e2d6aa97ef64a1740eb00e31e2f6814
sparse-checkout: update working directory in-process

The sparse-checkout builtin used 'git read-tree -mu HEAD' to update the
skip-worktree bits in the index and to update the working directory.
This extra process is overly complex, and prone to failure. It also
requires that we write our changes to the sparse-checkout file before
trying to update the index.

Remove this extra process call by creating a direct call to
unpack_trees() in the same way 'git read-tree -mu HEAD' does. In
addition, provide an in-memory list of patterns so we can avoid
reading from the sparse-checkout file. This allows us to test a
proposed change to the file before writing to it.

An earlier version of this patch included a bug when the 'set' command
failed due to the "Sparse checkout leaves no entry on working directory"
error. It would not rollback the index.lock file, so the replay of the
old sparse-checkout specification would fail. A test in t1091 now
covers that scenario.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/read-tree.c
builtin/sparse-checkout.c
t/t1091-sparse-checkout-builtin.sh
unpack-trees.c
unpack-trees.h