Subject: Re: [PATCH v5 15/17] sparse-checkout: update working directory in-process

From: SZEDER Gábor <[email-masked]>
Date: Tue, 19 Nov 2019 18:07:51 +0100

On Mon, Oct 21, 2019 at 01:56:24PM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <[email-masked]>
> 
> 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.

OK, the way I understand the above two paragraphs is that after this
patch it won't be necessary to write the updated patterns to the
'sparse-checkout' file before calling unpack_trees(), and to me it
implies that it won't be necessary to write the "include everything"
pattern to that file during disabling sparse checkout.

> @@ -378,7 +436,8 @@ static int sparse_checkout_disable(int argc, const char **argv)
>  	fprintf(fp, "/*\n");
>  	fclose(fp);

However, as the patch context here shows we still write that "include
everything" pattern to the 'sparse-checkout' file during disabling.

FWIW, deleting those lines updating the 'sparse-checkout' file make
the 'sparse-checkout disable' test fail.

Did I misunderstand what the commit message is trying to say?

> -	if (update_working_directory())
> +	core_apply_sparse_checkout = 1;
> +	if (update_working_directory(NULL))
>  		die(_("error while refreshing working directory"));
>  
>  	unlink(sparse_filename);