From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
"Randall S. Becker" <rsbecker@nexbridge.com>
Subject: Re: [PATCH] unit-tests: do show relative file paths on non-Windows, too
Date: Sun, 11 Feb 2024 11:03:55 +0000 [thread overview]
Message-ID: <6872b42d-8763-44dc-9502-2362d1ed80a7@gmail.com> (raw)
In-Reply-To: <xmqqttmf9y46.fsf@gitster.g>
Hi Junio
On 11/02/2024 08:57, Junio C Hamano wrote:
> There are compilers other than Visual C that want to show absolute
> paths. Generalize the helper introduced by a2c5e294 (unit-tests: do
> show relative file paths, 2023-09-25) so that it can also work with
> a path that uses slash as the directory separator, and becomes
> almost no-op once one-time preparation finds out that we are using a
> compiler that already gives relative paths. Incidentally, this also
> should do the right thing on Windows with a compiler that shows
> relative paths but with backslash as the directory separator (if
> such a thing exists and is used to build git).
>
> Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
> * Another change I made, which is not described in the proposed
> commit log message, is that we now use fspathcmp() instead of
> strcmp() to precompute the prefix length using a known needle[]
> string, to be consistent with the runtime check done for each and
> every path.
>
> This is a belated follow-up on <f0b804129e8a21449cbb6f346473d3570182ddfa.1695640837.git.gitgitgadget@gmail.com>
Thanks for putting this together - I was about to sit down and write
something similar when I saw your patch. I've left one comment below but
I don't think it is worth a re-roll, this looks good to me.
> + /*
> + * prefix_len == 0 if the compiler gives paths relative
> + * to the root of the working tree. Otherwise, we want
> + * to see that we did find the needle[] at a directory
> + * boundary.
> + */
> + if (fspathcmp(needle, prefix + prefix_len) ||
> + (prefix_len &&
> + prefix[prefix_len - 1] != '/' &&
> + prefix[prefix_len - 1] != '\\'))
We know which separator we're expecting so we could replace the last
two comparisons with
prefix[prefix_len -1] != needle[1]
but as I say I'm not sure that is worth re-rolling for
Best Wishes
Phillip
next prev parent reply other threads:[~2024-02-11 11:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-11 8:57 [PATCH] unit-tests: do show relative file paths on non-Windows, too Junio C Hamano
2024-02-11 11:03 ` Phillip Wood [this message]
2024-02-11 15:58 ` [PATCH v2] " Junio C Hamano
2024-02-12 10:44 ` Phillip Wood
2024-02-12 22:41 ` Junio C Hamano
2024-02-13 10:55 ` Phillip Wood
2024-02-13 17:10 ` Junio C Hamano
2024-02-13 19:58 ` Johannes Schindelin
2024-02-13 20:48 ` 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=6872b42d-8763-44dc-9502-2362d1ed80a7@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=phillip.wood@dunelm.org.uk \
--cc=rsbecker@nexbridge.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
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).