Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-13 Thread Junio C Hamano
SZEDER Gábor writes: > ... And that function must be able to handle multiple path > components, becase there is this callsite: > > exec-cmd.c: !(prefix = strip_path_suffix(executable_dirname, > GIT_EXEC_PATH)) && > > and the build sets '-DGIT_EXEC_PATH="libexec/git-core"' by default.

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-13 Thread Junio C Hamano
"brian m. carlson" writes: > Well, I split it out from a function that handles multiple path > components, mostly so that I could leverage existing work (and not have > to worry about getting it wrong). It wasn't explicitly intended that it > support multiple components, since I don't require tha

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-12 Thread SZEDER Gábor
On Mon, Aug 12, 2019 at 09:49:20AM -0700, Junio C Hamano wrote: > "brian m. carlson" writes: > > > On 2019-08-12 at 00:32:26, Junio C Hamano wrote: > >> "brian m. carlson" writes: > >> > +static ssize_t stripped_path_suffix_offset(const char *path, const char > >> > *suffix) > >> > >> Perhaps

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-12 Thread Jeff King
On Mon, Aug 12, 2019 at 10:40:21PM +, brian m. carlson wrote: > I think "ends_with_path_components" might be the way forward, unless > you think something else would be better. FWIW, having read the rest of the thread, that was the name that clicked for me. -Peff

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-12 Thread brian m. carlson
On 2019-08-12 at 16:49:20, Junio C Hamano wrote: > "brian m. carlson" writes: > > > On 2019-08-12 at 00:32:26, Junio C Hamano wrote: > >> "brian m. carlson" writes: > >> > +static ssize_t stripped_path_suffix_offset(const char *path, const char > >> > *suffix) > >> > >> Perhaps > >> > >>

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-12 Thread Junio C Hamano
"brian m. carlson" writes: > On 2019-08-12 at 00:32:26, Junio C Hamano wrote: >> "brian m. carlson" writes: >> > +static ssize_t stripped_path_suffix_offset(const char *path, const char >> > *suffix) >> >> Perhaps >> >> static ssize_t last_path_component_offset(const char *path, const cha

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-11 Thread SZEDER Gábor
On Mon, Aug 12, 2019 at 01:10:54AM +, brian m. carlson wrote: > On 2019-08-12 at 00:32:26, Junio C Hamano wrote: > > "brian m. carlson" writes: > > > +static ssize_t stripped_path_suffix_offset(const char *path, const char > > > *suffix) > > > > Perhaps > > > > static ssize_t last_path_

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-11 Thread brian m. carlson
On 2019-08-12 at 00:32:26, Junio C Hamano wrote: > "brian m. carlson" writes: > > +static ssize_t stripped_path_suffix_offset(const char *path, const char > > *suffix) > > Perhaps > > static ssize_t last_path_component_offset(const char *path, const char > *name) > > I am tempted to also

Re: [PATCH v2 1/2] path: add a function to check for path suffix

2019-08-11 Thread Junio C Hamano
"brian m. carlson" writes: > We have a function to strip the path suffix from a commit, but we don't > have one to check for a path suffix. For a plain filename, we can use > basename, but that requires an allocation, since POSIX allows it to > modify its argument. Refactor strip_path_suffix into

[PATCH v2 1/2] path: add a function to check for path suffix

2019-08-11 Thread brian m. carlson
We have a function to strip the path suffix from a commit, but we don't have one to check for a path suffix. For a plain filename, we can use basename, but that requires an allocation, since POSIX allows it to modify its argument. Refactor strip_path_suffix into a helper function and a new function