git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] unit-tests: do show relative file paths on non-Windows, too

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 13, 2024, 20:48 UTC
Message-ID
<xmqqzfw43xad.fsf@gitster.g>
In-Reply-To
<0fb4e912-b25e-0240-c49f-aac5cbc3ef9e@gmx.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 14 quoted lines
>> +		/*
>> +		 * The path could be relative (t/unit-tests/test-lib.c)
>> +		 * or full (/home/user/git/t/unit-tests/test-lib.c).
>> +		 * Check the slash between "t" and "unit-tests".
>> +		 */
>> +		prefix_len = len - needle_len;
>> +		if (prefix[prefix_len + 1] == '/') {
>> +			/* Oh, we're not Windows */
>> +			for (size_t i = 0; i < needle_len; i++)
>> +				if (needle[i] == '\\')
>> +					needle[i] = '/';
>
> This looks very similar to the `convert_slashes()` function that is
> defined in `compat/mingw.h`.

I lifted it from your later loop in the function, but given that many of the things that needed on Windows came from you, it is not surprising if you have another copy there ;-)

> It might be a good opportunity to rename that
> function and move it to `git-compat-util.h`, then use it here and once
> more below at the end of `make_relative()`.

Right. But not as part of the -rc fix. Let's leave it as #leftoverbits.

Thanks.
Previous: Johannes Schindelin
Message 9 of 9 in “unit-tests: do show relative file paths on non-Windows, too”
  1. unit-tests: do show relative file paths on non-Windows, tooJunio C Hamano, Feb 11, 2024
  2. Phillip WoodFeb 11, 2024
  3. unit-tests: do show relative file paths on non-Windows, tooJunio C Hamano, Feb 11, 2024
  4. Phillip WoodFeb 12, 2024
  5. Junio C HamanoFeb 12, 2024
  6. Phillip WoodFeb 13, 2024
  7. Junio C HamanoFeb 13, 2024
  8. Johannes SchindelinFeb 13, 2024
  9. Junio C HamanoFeb 13, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.