Skip to content

Features/sparse checkout - #5833

Open
jochenhz wants to merge 16 commits into
libgit2:mainfrom
jochenhz:features/sparse-checkout
Open

jochenhz wants to merge 16 commits into
libgit2:mainfrom
jochenhz:features/sparse-checkout

Conversation

@jochenhz

@jochenhz jochenhz commented Apr 3, 2021

Copy link
Copy Markdown
Contributor

Sparse Checkout

This is a proposal for a very basic but functional sparse checkout implementation in libgit2. As this is a major feature of git I can imagine that I am missing certain edge cases in git and libgit2 especially. It lacks certain features (see below) but I hope this might be a good start to improve and build upon.

What does this do?

  • Status / Diff takes GIT_INDEX_ENTRY_SKIP_WORKTREE into account
  • Skips sparse files on checkout
  • sparse-checkout file is treated as an attr_file, hence following gitignore rules
  • Sparse checkout can be enabled with core.sparseCheckout
  • Expose an interface function git_sparse_check_path to query whether or not a file is excluded from checkout
  • Set GIT_INDEX_ENTRY_SKIP_WORKTREE flag on git_index_read_tree based on the sparse-checkout ruleset.

What does it not do?

  • Smart trickery to determine whether or not a full tree is sparse (would be a very welcome optimization)
  • Support core.sparseCheckoutCone
  • No support for git sparse-checkout list
  • No direct support for git sparse-checkout reapply (but this can be achieved through checkout)
  • No direct support for git sparse-checkout add / set (so the sparse-checkout file has to be filled manually)
  • I guess no support for work trees? (I did not test this)
  • No sparse checkout option on clone (but this can be achieved with GIT_CHECKOUT_NONE and git_index_read_tree)

jochenhz added 16 commits April 3, 2021 13:33
…used by sparse checkout code as well

Signed-off-by: Jochen Hunz <[email protected]>
The sparse-checkout file is treated as a git_attr_file. A public API git_sparse_check_path reads the sparse-checkout file from the attribute file cache and checks the path against this attribute file using the gitignore ruleset

Signed-off-by: Jochen Hunz <[email protected]>
…es that are excluded by the sparse checkout ruleset - if sparse checkout is enabled

Signed-off-by: Jochen Hunz <[email protected]>
…accessed by checkout and diff functionalities quickly.

Signed-off-by: Jochen Hunz <[email protected]>
@jochenhz
jochenhz force-pushed the features/sparse-checkout branch from e0a0f5a to e3cb6de Compare April 3, 2021 13:22
@Sean-Oh

Sean-Oh commented Jul 16, 2021

Copy link
Copy Markdown

Is there any chance this PR will get merged? Would love to see sparse-checkout support in libgit2

@YuKitsune

Copy link
Copy Markdown

Is there any progress on this? I've got a fork that builds on this PR, happy to submit it here if it's of any value.

@YuKitsune YuKitsune mentioned this pull request Jan 12, 2022
@jochenhz

Copy link
Copy Markdown
Contributor Author

Sorry for not being responsive - I am still swamped in work. So thanks a lot @YuKitsune for your initiative!

@YuKitsune YuKitsune mentioned this pull request Aug 30, 2022
@shaybenh7

Copy link
Copy Markdown

any plans on merging this pull request?

@sigma67

sigma67 commented Jan 26, 2026

Copy link
Copy Markdown

It's been a while, any interest in reviving this PR? One of the few bigger limitations of libgit2 imo

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants