-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sparse path matching #36
Conversation
28ee79e
to
a781b9b
Compare
src/libgit2/sparse.c
Outdated
} | ||
|
||
if (match->length == 1 && match->pattern[0] == '*') { | ||
// NOTE(christoph): "/*" and "!/*/" both parse to "*", either to: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove your name from the note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/libgit2/sparse.c
Outdated
int *checkout, | ||
git_attr_file *file, | ||
git_attr_path *path) | ||
{ | ||
size_t j; | ||
git_attr_fnmatch *match; | ||
|
||
int path_length = strlen(path->path); | ||
if (is_top_level_file(path) ) { | ||
*checkout =GIT_SPARSE_CHECKOUT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is some tabs vs. spaces thing going on here leading to non-consistent whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work
Context
There was unexpected behavior on the following sparse checkout file:
Part of the problem is that prefixes like
example/
were not matching any of the include rules, so we never recursed into theexample/a/
directory for example.This prompted an investigation into no-cone vs cone and based on our reading of https://git-scm.com/docs/git-sparse-checkout, it's a better idea going forward to simply commit to cone mode.
Testing
make libgit2_tests && ./libgit2_tests -ssparse::paths
With:
The "A" folder becomes present in the workdir, with the "B" folder inside that, but "C" doesn't appear.
It seems like git operates as if
is equivalent to
but
by itself is ignored altogether.
Or maybe it's a path matching bug that intersects weirdly with the "always checkout top level files" rule.
Potentially some more experimentation needed, but bottom line, we now have a sane mental model on sparse matching as long as parent folders are included. I can also follow up to add a check for that.