Skip to content

Sparse Checkout - #6394

Open
YuKitsune wants to merge 56 commits into
libgit2:mainfrom
YuKitsune:features/sparse-checkout
Open

YuKitsune wants to merge 56 commits into
libgit2:mainfrom
YuKitsune:features/sparse-checkout

Conversation

@YuKitsune

Copy link
Copy Markdown

This PR aims to implement basic sparse checkout functionality into LibGit2 building on @jochenhz's original PR.

What does it do?

  • Status / Diff takes GIT_INDEX_ENTRY_SKIP_WORKTREE into account
  • sparse-checkout file is treated as an attr_file, hence following gitignore rules
  • Skips sparse files on checkout
  • Sparse checkout can be enabled with core.sparseCheckout
  • support init, set, add, reapply and disable commands all supported
  • 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 sparse checkout option on clone (but this can be achieved with GIT_CHECKOUT_NONE and git_index_read_tree)

Note

  • I've got some tests around worktrees, they seem to work
  • Given how complex sparse checkout can be, I'm almost certain I haven't gotten this implementation 100% correct, though feel free to prove me wrong 👍

@YuKitsune YuKitsune mentioned this pull request Aug 30, 2022
@YuKitsune
YuKitsune marked this pull request as ready for review August 30, 2022 23:09
jochenhz and others added 27 commits January 25, 2023 14:22
…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]>
- Temporarily remove cone references, will need to revisit
- Updating references in tests
@YuKitsune
YuKitsune force-pushed the features/sparse-checkout branch from 6958e3f to 4224906 Compare January 25, 2023 04:23
VinnyOG pushed a commit to 8thwall/libgit2-fork that referenced this pull request Jan 31, 2023
VinnyOG pushed a commit to 8thwall/libgit2-fork that referenced this pull request Mar 8, 2023
@MikeTheSnowman

MikeTheSnowman commented Sep 14, 2023 •

Copy link
Copy Markdown

This PR seems really promising with lots of people wanting sparse-checkout support. Not just directly from the libgit2 community (#2263), but also from all of the other projects that are built with libgit2. Are there any particular blockers for merging this? The last update seems to be from 8 months ago.

@abadran

abadran commented Jul 23, 2024

Copy link
Copy Markdown

@YuKitsune @jochenhz Can you comment on the status of the sparse-checkout branch? It seems like work was done on it 1 or 2 years ago and it's not been pulled back into the main libgit2 repo. I tried using it to read a sparse repo and it failed during reading the index. Is it known to work? Are there known issues/limitations?

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.

4 participants