-
Notifications
You must be signed in to change notification settings - Fork 141
sparse-checkout: allow one-character directories in cone mode #558
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
sparse-checkout: allow one-character directories in cone mode #558
Conversation
In 9e6d3e6 (sparse-checkout: detect short patterns, 2020-01-24), a condition on the minimum length of a cone-mode pattern was introduced. However, this condition was off-by-one. If we have a directory with a single character, say "b", then the command git sparse-checkout set b will correctly add the pattern "/b/" to the sparse-checkout file. When this is interpeted in dir.c, the pattern is "/b" with the PATTERN_FLAG_MUSTBEDIR flag. This string has length two, which satisfies our inclusive inequality (<= 2). The reason for this inequality is that we will start to read the pattern string character-by-character using three char pointers: prev, cur, next. In particular, next is set to the current pattern plus two. The mistake was that next will still be a valid pointer when the pattern length is two, since the string is null-terminated. Make this inequality strict so these patterns work. Signed-off-by: Derrick Stolee <[email protected]>
a4d20c0
to
c7209c9
Compare
/submit |
Submitted as [email protected] |
On the Git mailing list, Junio C Hamano wrote (reply to this):
|
This branch is now known as |
This patch series was integrated into pu via git@738f147. |
This patch series was integrated into pu via git@cd9aef4. |
This patch series was integrated into pu via git@3fc2e37. |
This patch series was integrated into next via git@de68d14. |
This patch series was integrated into pu via git@c463ce5. |
This patch series was integrated into pu via git@726665a. |
This patch series was integrated into pu via git@e8104ff. |
This patch series was integrated into pu via git@f4d7dfc. |
This patch series was integrated into next via git@f4d7dfc. |
This patch series was integrated into master via git@f4d7dfc. |
Closed via f4d7dfc. |
This is based on
ds/sparse-add
.I discovered this while taking v2.25.1 and
ds/sparse-add
into our fork of Git and testing it with Scalar.Off-by-one errors are tricky, sometimes.
Thanks,
-Stolee