threads / discuss / 40884

Sparse checkout in worktree

Subject: Sparse checkout in worktree

## tl;dr

6 messages between Nov 25, 2015 and Nov 25, 2015.

replies: 5people: 2as markdown or json

Michael J Gruber· Nov 25, 2015, 12:40 UTC · lore
Hi there,

I'm wondering how much it would take to enable worktree specific sparse checkouts. From a superfluous look:

- $GIT_DIR/info/sparse_checkout needs to be worktree specific
- We don't have much tooling around sparse to speak of at all.
The endgoal would be to have something like
git checkout [--sparse <pattern>]...

which sets up the sparse_checkout file and "git worktree" to pass any --sparse option on to "git checkout".

While in an ideal world we all have micro repos, in the real world we often have larger repos with mostly independent subdirs. For a quick fix on a side branch in a subdir, a new sparse worktree would be an ideal lean solution.

As it is, "git stash save && git checkout" is leaner but interrupts the workflow more, and a local "git clone" with links and alternates is leaner, too, but conceptually overkill if you want to work quickly on an existing side branch.

Cheers, Michael

Duy Nguyen· Nov 25, 2015, 19:38 UTC · re: Michael J Gruber · lore

Re: Sparse checkout in worktree

On Wed, Nov 25, 2015 at 1:40 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 6 quoted lines
> Hi there,
>
> I'm wondering how much it would take to enable worktree specific sparse
> checkouts. From a superfluous look:
>
> - $GIT_DIR/info/sparse_checkout needs to be worktree specific
It already is.
Show 8 quoted lines
> - We don't have much tooling around sparse to speak of at all.
>
> The endgoal would be to have something like
>
> git checkout [--sparse <pattern>]...
>
> which sets up the sparse_checkout file and "git worktree" to pass any
> --sparse option on to "git checkout"

Or.. convert pathspec specified at 'git-checkout' (or git-worktree) into sparse patterns. For example,

git worktree add --sparse some-path branch --  foo/

will automatically create sparse-checkout file that limits to 'foo'. Not easy (and in some cases probably impossible), but it's more intuitive. .

> While in an ideal world we all have micro repos, in the real world we
> often have larger repos with mostly independent subdirs. For a quick fix
> on a side branch in a subdir, a new sparse worktree would be an ideal
> lean solution.

Sparse checkout should eventually be replaced with something better that does not keep full tree in index, but I don't think anybody is working on that..

> As it is, "git stash save && git checkout" is leaner but interrupts the
> workflow more, and a local "git clone" with links and alternates is
> leaner, too, but conceptually overkill if you want to work quickly on an
> existing side branch.

-- Duy

Michael J Gruber· Nov 25, 2015, 19:44 UTC · re: Duy Nguyen · lore

Re: Sparse checkout in worktree

Duy Nguyen venit, vidit, dixit 25.11.2015 20:38:
Show 10 quoted lines
> On Wed, Nov 25, 2015 at 1:40 PM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Hi there,
>>
>> I'm wondering how much it would take to enable worktree specific sparse
>> checkouts. From a superfluous look:
>>
>> - $GIT_DIR/info/sparse_checkout needs to be worktree specific
> 
> It already is.

But where should I put the worktree specific sparse_checkout file? Is Documentation/technical really the only place to find information about this? And to make the existing tree sparse, do I need to rm -r and checkout sparsely?

Michael
Duy Nguyen· Nov 25, 2015, 20:17 UTC · re: Michael J Gruber · lore

Re: Sparse checkout in worktree

On Wed, Nov 25, 2015 at 8:44 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 16 quoted lines
> Duy Nguyen venit, vidit, dixit 25.11.2015 20:38:
>> On Wed, Nov 25, 2015 at 1:40 PM, Michael J Gruber
>> <git@drmicha.warpmail.net> wrote:
>>> Hi there,
>>>
>>> I'm wondering how much it would take to enable worktree specific sparse
>>> checkouts. From a superfluous look:
>>>
>>> - $GIT_DIR/info/sparse_checkout needs to be worktree specific
>>
>> It already is.
>
> But where should I put the worktree specific sparse_checkout file? Is
> Documentation/technical really the only place to find information about
> this? And to make the existing tree sparse, do I need to rm -r and
> checkout sparsely?

Ahh.. worktree-specific files of the checkout "foo" stay in $GIT_DIR/repos/foo. So sparse-checkout path should be $GIT_DIR/repos/foo/info/sparse-checkout. This is another good reason to add 'git checkout --edit-sparse' that opens the sparse-checkout file for you to update. Or you could use 'git rev-parse --git-path info/sparse-checkout" to get full path.

-- 
Duy
Michael J Gruber· Nov 25, 2015, 20:44 UTC · re: Duy Nguyen · lore

Re: Sparse checkout in worktree

Duy Nguyen venit, vidit, dixit 25.11.2015 21:17:
Show 26 quoted lines
> On Wed, Nov 25, 2015 at 8:44 PM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Duy Nguyen venit, vidit, dixit 25.11.2015 20:38:
>>> On Wed, Nov 25, 2015 at 1:40 PM, Michael J Gruber
>>> <git@drmicha.warpmail.net> wrote:
>>>> Hi there,
>>>>
>>>> I'm wondering how much it would take to enable worktree specific sparse
>>>> checkouts. From a superfluous look:
>>>>
>>>> - $GIT_DIR/info/sparse_checkout needs to be worktree specific
>>>
>>> It already is.
>>
>> But where should I put the worktree specific sparse_checkout file? Is
>> Documentation/technical really the only place to find information about
>> this? And to make the existing tree sparse, do I need to rm -r and
>> checkout sparsely?
> 
> Ahh.. worktree-specific files of the checkout "foo" stay in
> $GIT_DIR/repos/foo. So sparse-checkout path should be
> $GIT_DIR/repos/foo/info/sparse-checkout. This is another good reason
> to add 'git checkout --edit-sparse' that opens the sparse-checkout
> file for you to update. Or you could use 'git rev-parse --git-path
> info/sparse-checkout" to get full path.
> 
[ "worktrees", not "repos" ]

Maybe creating an empty info dir by default would help already - I had looked in there but didn't find anything.

OTOH, config is common: core.sparseCheckout So, the per worktree "switch" is the presence of the sparse-checkout file.

Michael
Duy Nguyen· Nov 25, 2015, 20:50 UTC · re: Michael J Gruber · lore

Re: Sparse checkout in worktree

On Wed, Nov 25, 2015 at 9:44 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

> OTOH, config is common: core.sparseCheckout
> So, the per worktree "switch" is the presence of the sparse-checkout file.

Oh.. but yeah, splitting config file per worktree is on my todo list. Or you can help finish it [1] if you want to make it happen faster

[1] http://article.gmane.org/gmane.comp.version-control.git/266520
-- 
Duy

← back to recent threads