Re: [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item

2018-04-06 Thread Jeff King
On Thu, Apr 05, 2018 at 01:06:30PM -0700, Elijah Newren wrote: > > There are other similar trailing-slash matches in that function, but I'm > > not sure of all the cases in which they're used. I don't know if any of > > those would need similar treatment (sorry for being vague; I expect I'd > >

Re: [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item

2018-04-05 Thread Elijah Newren
On Thu, Apr 5, 2018 at 12:04 PM, Jeff King wrote: > On Thu, Apr 05, 2018 at 11:36:45AM -0700, Elijah Newren wrote: > >> > Do we care about matching the name "foo" against the patchspec_item "foo/"? >> > >> > That matches now, but wouldn't after your patch. >> >> So I should

Re: [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item

2018-04-05 Thread Jeff King
On Thu, Apr 05, 2018 at 11:36:45AM -0700, Elijah Newren wrote: > > Do we care about matching the name "foo" against the patchspec_item "foo/"? > > > > That matches now, but wouldn't after your patch. > > Technically, the tests pass anyway due to the fallback behavior > mentioned in the commit

Re: [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item

2018-04-05 Thread Elijah Newren
On Thu, Apr 5, 2018 at 10:49 AM, Jeff King wrote: >> diff --git a/dir.c b/dir.c >> index 19212129f0..c915a69385 100644 >> --- a/dir.c >> +++ b/dir.c >> @@ -384,7 +384,7 @@ static int match_pathspec_item(const struct >> pathspec_item *item, int prefix, >> if (flags &

Re: [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item

2018-04-05 Thread Jeff King
On Thu, Apr 05, 2018 at 10:34:41AM -0700, Elijah Newren wrote: > For a pathspec like 'foo/bar' comparing against a path named "foo/", > namelen will be 4, and match[namelen] will be 'b'. The correct location > of the directory separator is namelen-1. > > The reason the code worked anyway was