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

Re: [PATCH v1] handle lower case drive letters on Windows

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 12, 2018, 13:59 UTC
Message-ID
<nycvar.QRO.7.76.6.1807121556030.75@tvgsbejvaqbjf.bet>
In-Reply-To
<20180711175420.16940-1-benpeart@microsoft.com>
Hi Ben,
On Wed, 11 Jul 2018, Ben Peart wrote:
> Teach test-drop-caches to handle lower case drive letters on Windows.

Maybe mention that you can trigger this by using a lower case drive letter in Powershell (CMD normalizes your path, Powershell does not).

Show 11 quoted lines
> diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
> index d6bcfddf13..37047189c3 100644
> --- a/t/helper/test-drop-caches.c
> +++ b/t/helper/test-drop-caches.c
> @@ -16,7 +16,7 @@ static int cmd_sync(void)
>  	if ((0 == dwRet) || (dwRet > MAX_PATH))
>  		return error("Error getting current directory");
>  
> -	if ((Buffer[0] < 'A') || (Buffer[0] > 'Z'))
> +	if ((toupper(Buffer[0]) < 'A') || (toupper(Buffer[0]) > 'Z'))
>  		return error("Invalid drive letter '%c'", Buffer[0]);

This is a rather incomplete test, as it does not even test for the colon after the drive letter.

But I guess the more common case where this code path triggers the error is when your current directory is a UNC path to a file share (again, only possible in Powershell, CMD does not let you do that unless you play serious tricks).

So maybe a much better idea is to use our `has_dos_drive_prefix()` function:

	if (!has_dos_drive_prefix(Buffer))
		return error("'%s': invalid drive letter", Buffer);

Ciao, Johannes

Previous: Ben PeartNext: Junio C Hamano
Message 7 of 15 in “handle lower case drive letters on Windows”
  1. handle lower case drive letters on WindowsBen Peart, Jul 11, 2018
  2. Stefan BellerJul 11, 2018
  3. Ben PeartJul 11, 2018
  4. Junio C HamanoJul 11, 2018
  5. Ben PeartJul 11, 2018
  6. handle lower case drive letters on WindowsBen Peart, Jul 11, 2018
  7. Johannes SchindelinJul 12, 2018
  8. Junio C HamanoJul 12, 2018
  9. handle lower case drive letters on WindowsBen Peart, Jul 12, 2018
  10. Junio C HamanoJul 12, 2018
  11. Ben PeartJul 12, 2018
  12. Junio C HamanoJul 12, 2018
  13. Ben PeartJul 12, 2018
  14. Junio C HamanoJul 12, 2018
  15. Johannes SchindelinJul 14, 2018

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.