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

2018-07-14 Thread Johannes Schindelin
Hi Junio,

On Thu, 12 Jul 2018, Junio C Hamano wrote:

> Ben Peart  writes:
> 
> >> > Thanks.  I thought it was strange as well until I realized you only
> >> > see the error message if there _isn't_ a valid drive letter so seeing
> >> > the entire path makes sense as it will likely be something like
> >> "\\server\volume\directory"
> >> 
> >> Yup, that is why I thought Dscho meant to say something like
> >> 
> >>"'%s': path without valid drive prefix"
> >> 
> >> in my response ;-)
> >
> > I'm fine with that - want me to leave it alone, spin a V4 or have you tweak 
> > it?
> 
> That's "helped-by Dscho" patch, so I'd leave it to him by queuing v3
> overnight and wait to deal with the final decision by the weekend
> ;-) That way, I do not have to make a decision on anything Windows
> related.

The tweaked error message is fine by me.

Ciao,
Dscho


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

2018-07-12 Thread Junio C Hamano
Ben Peart  writes:

>> > Thanks.  I thought it was strange as well until I realized you only
>> > see the error message if there _isn't_ a valid drive letter so seeing
>> > the entire path makes sense as it will likely be something like
>> "\\server\volume\directory"
>> 
>> Yup, that is why I thought Dscho meant to say something like
>> 
>>  "'%s': path without valid drive prefix"
>> 
>> in my response ;-)
>
> I'm fine with that - want me to leave it alone, spin a V4 or have you tweak 
> it?

That's "helped-by Dscho" patch, so I'd leave it to him by queuing v3
overnight and wait to deal with the final decision by the weekend
;-) That way, I do not have to make a decision on anything Windows
related.


RE: [PATCH v3] handle lower case drive letters on Windows

2018-07-12 Thread Ben Peart
> > Thanks.  I thought it was strange as well until I realized you only
> > see the error message if there _isn't_ a valid drive letter so seeing
> > the entire path makes sense as it will likely be something like
> "\\server\volume\directory"
> 
> Yup, that is why I thought Dscho meant to say something like
> 
>   "'%s': path without valid drive prefix"
> 
> in my response ;-)

I'm fine with that - want me to leave it alone, spin a V4 or have you tweak it?


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

2018-07-12 Thread Junio C Hamano
Ben Peart  writes:

>> -Original Message-
>> From: Junio C Hamano  On Behalf Of Junio C Hamano
>> Sent: Thursday, July 12, 2018 3:13 PM
>> To: Ben Peart 
>> Cc: git@vger.kernel.org; sbel...@google.com; johannes.schinde...@gmx.de
>> Subject: Re: [PATCH v3] handle lower case drive letters on Windows
>> 
>> Ben Peart  writes:
>> 
>> > On Windows, if a tool calls SetCurrentDirectory with a lower case drive
>> > letter, the subsequent call to GetCurrentDirectory will return the same
>> > lower case drive letter. Powershell, for example, does not normalize the
>> > path. If that happens, test-drop-caches will error out as it does not
>> > correctly to handle lower case drive letters.
>> >
>> > Helped-by: Johannes Schindelin 
>> > Signed-off-by: Ben Peart 
>> > ---
>> 
>> Thanks.  Will replace, even though showing the whole Buffer (I am
>> guessing it is the equivalent of result from getcwd(3) call) and
>> complaining about drive "letter" feels a bit strange ;-)
>> 
>
> Thanks.  I thought it was strange as well until I realized you only see the
> error message if there _isn't_ a valid drive letter so seeing the entire
> path makes sense as it will likely be something like 
> "\\server\volume\directory"

Yup, that is why I thought Dscho meant to say something like

"'%s': path without valid drive prefix"

in my response ;-)



RE: [PATCH v3] handle lower case drive letters on Windows

2018-07-12 Thread Ben Peart
> -Original Message-
> From: Junio C Hamano  On Behalf Of Junio C Hamano
> Sent: Thursday, July 12, 2018 3:13 PM
> To: Ben Peart 
> Cc: git@vger.kernel.org; sbel...@google.com; johannes.schinde...@gmx.de
> Subject: Re: [PATCH v3] handle lower case drive letters on Windows
> 
> Ben Peart  writes:
> 
> > On Windows, if a tool calls SetCurrentDirectory with a lower case drive
> > letter, the subsequent call to GetCurrentDirectory will return the same
> > lower case drive letter. Powershell, for example, does not normalize the
> > path. If that happens, test-drop-caches will error out as it does not
> > correctly to handle lower case drive letters.
> >
> > Helped-by: Johannes Schindelin 
> > Signed-off-by: Ben Peart 
> > ---
> 
> Thanks.  Will replace, even though showing the whole Buffer (I am
> guessing it is the equivalent of result from getcwd(3) call) and
> complaining about drive "letter" feels a bit strange ;-)
> 

Thanks.  I thought it was strange as well until I realized you only see the
error message if there _isn't_ a valid drive letter so seeing the entire
path makes sense as it will likely be something like "\\server\volume\directory"


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

2018-07-12 Thread Junio C Hamano
Ben Peart  writes:

> On Windows, if a tool calls SetCurrentDirectory with a lower case drive
> letter, the subsequent call to GetCurrentDirectory will return the same
> lower case drive letter. Powershell, for example, does not normalize the
> path. If that happens, test-drop-caches will error out as it does not
> correctly to handle lower case drive letters.
>
> Helped-by: Johannes Schindelin 
> Signed-off-by: Ben Peart 
> ---

Thanks.  Will replace, even though showing the whole Buffer (I am
guessing it is the equivalent of result from getcwd(3) call) and
complaining about drive "letter" feels a bit strange ;-)

> Notes:
> Base Ref: master
> Web-Diff: https://github.com/benpeart/git/commit/1ff8de1b6c
> Checkout: git fetch https://github.com/benpeart/git drop-caches-v3 && git 
> checkout 1ff8de1b6c
> 
> ### Interdiff (v2..v3):
> 
> diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
> index 37047189c3..f65e301f9d 100644
> --- a/t/helper/test-drop-caches.c
> +++ b/t/helper/test-drop-caches.c
> @@ -16,8 +16,8 @@ static int cmd_sync(void)
>   if ((0 == dwRet) || (dwRet > MAX_PATH))
>   return error("Error getting current directory");
> 
> - if ((toupper(Buffer[0]) < 'A') || (toupper(Buffer[0]) > 'Z'))
> - return error("Invalid drive letter '%c'", Buffer[0]);
> + if (!has_dos_drive_prefix(Buffer))
> + return error("'%s': invalid drive letter", Buffer);
> 
>   szVolumeAccessPath[4] = Buffer[0];
>   hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
> 
> ### Patches
>
>  t/helper/test-drop-caches.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
> index d6bcfddf13..f65e301f9d 100644
> --- a/t/helper/test-drop-caches.c
> +++ b/t/helper/test-drop-caches.c
> @@ -16,8 +16,8 @@ static int cmd_sync(void)
>   if ((0 == dwRet) || (dwRet > MAX_PATH))
>   return error("Error getting current directory");
>  
> - if ((Buffer[0] < 'A') || (Buffer[0] > 'Z'))
> - return error("Invalid drive letter '%c'", Buffer[0]);
> + if (!has_dos_drive_prefix(Buffer))
> + return error("'%s': invalid drive letter", Buffer);
>  
>   szVolumeAccessPath[4] = Buffer[0];
>   hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
>
> base-commit: e3331758f12da22f4103eec7efe1b5304a9be5e9


[PATCH v3] handle lower case drive letters on Windows

2018-07-12 Thread Ben Peart
On Windows, if a tool calls SetCurrentDirectory with a lower case drive
letter, the subsequent call to GetCurrentDirectory will return the same
lower case drive letter. Powershell, for example, does not normalize the
path. If that happens, test-drop-caches will error out as it does not
correctly to handle lower case drive letters.

Helped-by: Johannes Schindelin 
Signed-off-by: Ben Peart 
---

Notes:
Base Ref: master
Web-Diff: https://github.com/benpeart/git/commit/1ff8de1b6c
Checkout: git fetch https://github.com/benpeart/git drop-caches-v3 && git 
checkout 1ff8de1b6c

### Interdiff (v2..v3):

diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index 37047189c3..f65e301f9d 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -16,8 +16,8 @@ static int cmd_sync(void)
if ((0 == dwRet) || (dwRet > MAX_PATH))
return error("Error getting current directory");

-   if ((toupper(Buffer[0]) < 'A') || (toupper(Buffer[0]) > 'Z'))
-   return error("Invalid drive letter '%c'", Buffer[0]);
+   if (!has_dos_drive_prefix(Buffer))
+   return error("'%s': invalid drive letter", Buffer);

szVolumeAccessPath[4] = Buffer[0];
hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,

### Patches

 t/helper/test-drop-caches.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index d6bcfddf13..f65e301f9d 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -16,8 +16,8 @@ static int cmd_sync(void)
if ((0 == dwRet) || (dwRet > MAX_PATH))
return error("Error getting current directory");
 
-   if ((Buffer[0] < 'A') || (Buffer[0] > 'Z'))
-   return error("Invalid drive letter '%c'", Buffer[0]);
+   if (!has_dos_drive_prefix(Buffer))
+   return error("'%s': invalid drive letter", Buffer);
 
szVolumeAccessPath[4] = Buffer[0];
hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,

base-commit: e3331758f12da22f4103eec7efe1b5304a9be5e9
-- 
2.17.0.gvfs.1.123.g449c066