git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	git@vger.kernel.org, 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: Tue, 13 Aug 2019 08:36:18 +0200	[thread overview]
Message-ID: <20190813063618.GO20404@szeder.dev> (raw)
In-Reply-To: <xmqq7e7iba7j.fsf@gitster-ct.c.googlers.com>

On Mon, Aug 12, 2019 at 09:49:20AM -0700, 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?

The plural in the suggested function name was intentional on my part,
even though in this callsite in question we are only interested in the
filename, i.e. only a single path component.

I was hoping that the names of these related functions will be kept in
sync, and all will somehow contain the "path_components" substring,
e.g. strip_path_suffix() becomes strip_suffix_path_components() or
something.  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.


  parent reply	other threads:[~2019-08-13  6:36 UTC|newest]

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
2019-08-13  1:13             ` Jeff King
2019-08-13 16:40             ` Junio C Hamano
2019-08-13  6:36           ` SZEDER Gábor [this message]
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=20190813063618.GO20404@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).