On 2019-08-09 at 13:51:49, Jeff King wrote: > On Fri, Aug 09, 2019 at 02:43:18PM +0200, SZEDER Gábor wrote: > > But there is an other subtlety here: when I read the commit message > > saying "patch that touches a path ending in ".gitattributes"." and saw > > the new call to strip_path_suffix(), I immediately thought what would > > happen with a file called 'foo.gitattributes'. Only when I looked > > into strip_path_suffix() became it clear that it only removes full > > path components, so such a filename won't cause any trouble (though > > perhaps the worst thing that could happen is that we unnecessarily > > flush the attributes cache). > > Right. I think the term we want here is really "basename". So in fact: > > if (!strcmp(basename(patch->new_name), GITATTRIBUTES_FILE)) > > would do what we want, except for the annoying caveat that basename() is > allowed to modify its parameter (to remove trailing directory > separators, but we know we wouldn't have them here). I think this is exactly the function I'm looking for. I'm a little uncomfortable relying on the fact that typical implementations don't modify the string when there's no trailing slash, though. I think I'm going to end up refactoring out the strip_path_suffix function into a has_path_suffix and use that. That will avoid the allocation and it doesn't rely on the generosity of OS implementers. -- brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204