git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, SZEDER Gábor <szeder.dev@gmail.com>,
	Taylor Blau <me@ttaylorr.com>, Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 1/2] path: add a function to check for path suffix
Date: Mon, 12 Aug 2019 22:40:21 +0000
Message-ID: <20190812224021.GA229582@genre.crustytoothpaste.net> (raw)
In-Reply-To: <xmqq7e7iba7j.fsf@gitster-ct.c.googlers.com>

[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]

On 2019-08-12 at 16:49:20, Junio C Hamano wrote:
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> 
> > On 2019-08-12 at 00:32:26, Junio C Hamano wrote:
> >> "brian m. carlson" <sandals@crustytoothpaste.net> 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 call the second parameter to this function
> >> "basename", as we know from the proposed log message that you wish
> >> "basename" were usable for this purpose, but basename itself has
> >> another confusing factor (i.e. "are we stripping ".exe" extension?",
> >> to which the answer is no in the context of these functions).
> >> 
> >> If we agree with the "last path component" phrasing, has_path_suffix()
> >> would become something like:
> >> 
> >>     int last_path_component_equals(const char *path, const char *name);
> >
> > Except this is not necessarily the last path component. It could match
> > one or more path components with the way the function is written.
> 
> That's fair.  Is the feature that allows the function called
> ends_with_component*S* like Szeder suggests designed one, i.e. with
> an explicit purpose of supporting callers that pass "foo/bar" as the
> "suffix" to it, or is it merely that the implementation happens to
> work that way, even though the expected use that is supported is to
> pass only one level component but the implementation did not even
> bother asserting that the "suffix" does not have a slash in it?

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 that for my
implementation, but I could see future users taking advantage of that.

I think "ends_with_path_components" might be the way forward, unless
you think something else would be better.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

  reply index

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 10:02 [PATCH] apply: reload .gitattributes after patching it brian m. carlson
2019-08-09 11:14 ` Taylor Blau
2019-08-09 11:25   ` brian m. carlson
2019-08-09 11:36     ` Jeff King
2019-08-09 11:47       ` brian m. carlson
2019-08-09 12:43       ` SZEDER Gábor
2019-08-09 13:51         ` Jeff King
2019-08-09 22:08           ` brian m. carlson
2019-08-11 17:47 ` [PATCH v2 0/2] Honor .gitattributes with rebase --am brian m. carlson
2019-08-11 17:47   ` [PATCH v2 1/2] path: add a function to check for path suffix brian m. carlson
2019-08-12  0:32     ` Junio C Hamano
2019-08-12  1:10       ` brian m. carlson
2019-08-12  4:36         ` SZEDER Gábor
2019-08-12 16:49         ` Junio C Hamano
2019-08-12 22:40           ` brian m. carlson [this message]
2019-08-13  1:13             ` Jeff King
2019-08-13 16:40             ` Junio C Hamano
2019-08-13  6:36           ` SZEDER Gábor
2019-08-13 16:42             ` Junio C Hamano
2019-08-11 17:47   ` [PATCH v2 2/2] apply: reload .gitattributes after patching it brian m. carlson
2019-08-13  2:43 ` [PATCH v3 0/2] Honor .gitattributes with rebase --am brian m. carlson
2019-08-13  2:43   ` [PATCH v3 1/2] path: add a function to check for path suffix brian m. carlson
2019-08-13  2:43   ` [PATCH v3 2/2] apply: reload .gitattributes after patching it brian m. carlson
2019-08-13 18:08     ` Junio C Hamano
2019-08-15 22:10       ` Junio C Hamano
2019-08-16  0:22         ` brian m. carlson
2019-08-13 22:37     ` Junio C Hamano
2019-08-13 22:48       ` brian m. carlson
2019-08-18 18:44 ` [PATCH v4 0/2] Honor .gitattributes with rebase --am brian m. carlson
2019-08-18 18:44   ` [PATCH v4 1/2] path: add a function to check for path suffix brian m. carlson
2019-08-18 18:44   ` [PATCH v4 2/2] apply: reload .gitattributes after patching it brian m. carlson
2019-08-19  9:41     ` Phillip Wood
2019-08-19  9:55       ` Phillip Wood
2019-08-20  3:05         ` brian m. carlson
2019-08-20  8:56           ` Phillip Wood
2019-08-20  2:45       ` brian m. carlson
2019-08-20  8:52         ` Phillip Wood
2019-08-20 18:24           ` Junio C Hamano
2019-08-20 18:32             ` Phillip Wood
2019-08-26 15:09               ` Phillip Wood
2019-08-26 16:41                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190812224021.GA229582@genre.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git