Re: [PATCH v2] dir: check for single file cone patterns
From: Junio C Hamano <hidden>
Date: 2023-01-05 02:16:27
Victoria Dye [off-list ref] writes:
This clearly explains the issue you're trying to fix: cone mode sparse-checkout requires patterns like '/A/B/', !/A/B/*/', '/A/B/C/', etc., but invalid patterns like '/A/B/C' (no trailing slash) currently don't force the switch to non-cone mode, leading to unexpected behavior. ...quoted
To fix these issues, add a cone mode pattern check that asserts that every pattern is either a directory match or the pattern '/*'. Add a test to verify the new pattern check and modify another to reflect that non-directory patterns are caught earlier.I think this is the best way to maintain the current intended behavior of cone mode sparse-checkout. While the idea of single file "exceptions" to cone patterns has been brought up in the past (I think most recently at the Contributor's Summit this past September [1]), it'd be a substantial change that's definitely out-of-scope of this small bugfix. ... And this test ensures the new check is working for the appropriate patterns. This patch looks good to me, thanks for finding & fixing the bug!
Thanks for an excellently written review, and a patch that is well done. Will queue.