threads / patch / 50893

patchUnbreak real_path on Windows for already absolute paths (with Visual Studio)

Subject: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

## tl;dr

10 messages between Apr 8, 2019 and Apr 12, 2019. Diffs are folded; open one to read it.

replies: 9people: 5as markdown or json

Sven Strickroth· Apr 8, 2019, 11:16 UTC · lore

A path such as 'c:/somepath/submodule/../.git/modules/submodule' wasn't resolved correctly any more, because the *nix variant of offset_1st_component is used instead of the Win32 specific version.

Regression was introduced in commit 25d90d1cb72ce51407324259516843406142fe89.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
---
 git-compat-util.h | 1 +
 1 file changed, 1 insertion(+)
Show changes to git-compat-util.h +1 −0
diff --git a/git-compat-util.h b/git-compat-util.h
index e0275da7e0..9be177e588 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -210,6 +210,7 @@
 #include "compat/mingw.h"
 #include "compat/win32/fscache.h"
 #elif defined(_MSC_VER)
+#include "compat/win32/path-utils.h"
 #include "compat/msvc.h"
 #include "compat/win32/fscache.h"
 #else
-- 
2.21.0.windows.1
Taylor Blau· Apr 9, 2019, 02:36 UTC · re: Sven Strickroth · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

Hi Sven,
On Mon, Apr 08, 2019 at 01:16:33PM +0200, Sven Strickroth wrote:
> A path such as 'c:/somepath/submodule/../.git/modules/submodule' wasn't
> resolved correctly any more, because the *nix variant of
> offset_1st_component is used instead of the Win32 specific version.

I'm not a win32 expert by any sense, but I am do have a meta-question about your patch...

> Regression was introduced in commit
> 25d90d1cb72ce51407324259516843406142fe89.

I can't seem to find this commit anywhere upstream. Is this SHA-1 pasted correctly?

Show 20 quoted lines
>
> Signed-off-by: Sven Strickroth <email@cs-ware.de>
> ---
>  git-compat-util.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index e0275da7e0..9be177e588 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -210,6 +210,7 @@
>  #include "compat/mingw.h"
>  #include "compat/win32/fscache.h"
>  #elif defined(_MSC_VER)
> +#include "compat/win32/path-utils.h"
>  #include "compat/msvc.h"
>  #include "compat/win32/fscache.h"
>  #else
> --
> 2.21.0.windows.1

Thanks, Taylor

Torsten Bögershausen· Apr 9, 2019, 05:53 UTC · re: Sven Strickroth · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

On 2019-04-08 13:16, Sven Strickroth wrote:
Show 6 quoted lines
> A path such as 'c:/somepath/submodule/../.git/modules/submodule' wasn't
> resolved correctly any more, because the *nix variant of
> offset_1st_component is used instead of the Win32 specific version.
>
> Regression was introduced in commit
> 25d90d1cb72ce51407324259516843406142fe89.

Was it ? 25d90d1cb merged this commit: 1cadad6f6 (junio/tb/use-common-win32-pathfuncs-on-cygwin)

And, if I read that correctly, 1cadad6f6 does not change anything for MSVC. And the problem with the missing/wrong path resolution was there before 1cadad6f6 and after 1cadad6f6.

From that point of view, the patch looks correct, but:
The other question:
In config.mak.uname  we need to add a line
compat/win32/path-utils.o
for the Windows build.
In the git-for windows codebase I see
  COMPAT_OBJS +=compat/win32/path-utils

3 times: For Cygwin, MINGW and Windows.

In git.git only for Cygwin and MINGW.
(I don't have MSVC, so I can't test)
Show 19 quoted lines
>
> Signed-off-by: Sven Strickroth <email@cs-ware.de>
> ---
>  git-compat-util.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index e0275da7e0..9be177e588 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -210,6 +210,7 @@
>  #include "compat/mingw.h"
>  #include "compat/win32/fscache.h"
>  #elif defined(_MSC_VER)
> +#include "compat/win32/path-utils.h"
>  #include "compat/msvc.h"
>  #include "compat/win32/fscache.h"
>  #else
>
Sven Strickroth· Apr 9, 2019, 07:34 UTC · re: Torsten Bögershausen · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

Am 09.04.2019 um 07:53 schrieb Torsten Bögershausen:
Show 6 quoted lines
>> Regression was introduced in commit
>> 25d90d1cb72ce51407324259516843406142fe89.
> 
> Was it ?
> 25d90d1cb merged this commit:
> 1cadad6f6 (junio/tb/use-common-win32-pathfuncs-on-cygwin)
Yes, I copied the revision of the merge commit.
> And, if I read that correctly,  1cadad6f6 does not change anything for MSVC.
> And the problem with the missing/wrong path resolution was there before
> 1cadad6f6 and after 1cadad6f6.

That's not correct, it was correct before: 1cadad6f6 removes mingw_offset_1st_component from mingw.c which is included by msvc.c. Then the in git-compat.h the new file "compat/win32/path-utils.h" is only included for __CYGWIN__ and __MINGW32__, here _MSC_VER is missing -> that's the regression.

Show 5 quoted lines
> In config.mak.uname  we need to add a line
> compat/win32/path-utils.o
> for the Windows build.
> In the git-for windows codebase I see
>   COMPAT_OBJS +=compat/win32/path-utils
I don't use config.mak.uname and never did, so I can't tell you about that.
-- 
Best regards,
 Sven Strickroth
 PGP key id F5A9D4C4 @ any key-server
Sven Strickroth· Apr 8, 2019, 11:26 UTC · re: Sven Strickroth · lore

[PATCH v2] MSVC: Unbreak real_path for Windows paths

A path such as 'c:/somepath/submodule/../.git/modules/submodule' wasn't resolved correctly any more, because the *nix variant of offset_1st_component is used instead of the Win32 specific version.

Regression was introduced in commit 1cadad6f6 when mingw_offset_1st_component was moved from mingw.c which is included by msvc.c to a separate file. Then, the new file "compat/win32/path-utils.h" was only included for the __CYGWIN__ and __MINGW32__ cases in git-compat-util.h, the case for _MSC_VER was missing.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
---
 config.mak.uname  | 1 +
 git-compat-util.h | 1 +
 2 files changed, 2 insertions(+)
Show changes to 2 files +2 −0

config.mak.uname, git-compat-util.h

diff --git a/config.mak.uname b/config.mak.uname
index 32381f5fd1..eb1428858c 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -426,6 +426,7 @@ ifeq ($(uname_S),Windows)
 	CFLAGS =
 	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
 	COMPAT_OBJS = compat/msvc.o compat/winansi.o \
+		compat/win32/path-utils.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
 		compat/win32/dirent.o compat/win32/fscache.o
 	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
diff --git a/git-compat-util.h b/git-compat-util.h
index e0275da7e0..9be177e588 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -210,6 +210,7 @@
 #include "compat/mingw.h"
 #include "compat/win32/fscache.h"
 #elif defined(_MSC_VER)
+#include "compat/win32/path-utils.h"
 #include "compat/msvc.h"
 #include "compat/win32/fscache.h"
 #else
-- 
2.21.0.windows.1
Junio C Hamano· Apr 9, 2019, 11:45 UTC · re: Sven Strickroth · lore

Re: [PATCH v2] MSVC: Unbreak real_path for Windows paths

Sven Strickroth <email@cs-ware.de> writes:
Show 14 quoted lines
> A path such as 'c:/somepath/submodule/../.git/modules/submodule' wasn't
> resolved correctly any more, because the *nix variant of offset_1st_component
> is used instead of the Win32 specific version.
>
> Regression was introduced in commit 1cadad6f6 when mingw_offset_1st_component
> was moved from mingw.c which is included by msvc.c to a separate file. Then,
> the new file "compat/win32/path-utils.h" was only included for the __CYGWIN__
> and __MINGW32__ cases in git-compat-util.h, the case for _MSC_VER was missing.
>
> Signed-off-by: Sven Strickroth <email@cs-ware.de>
> ---
>  config.mak.uname  | 1 +
>  git-compat-util.h | 1 +
>  2 files changed, 2 insertions(+)

Some context lines in config.mak.uname did not match tips of any of the well-known branches I tried, and the blob object name recorded on the "index" line was not useful, either, so I ended up applying the patch by hand. I do not think I screwed up a simple two-liner patch like this too badly ;-), but please keep an eye on what will appear on 'pu' and holler if I did, so we can correct it before it hits 'master'.

Thanks.
Show 8 quoted lines
>
> diff --git a/config.mak.uname b/config.mak.uname
> index 32381f5fd1..eb1428858c 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -426,6 +426,7 @@ ifeq ($(uname_S),Windows)
>  	CFLAGS =
>  	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
Torsten Bögershausen· Apr 9, 2019, 16:19 UTC · re: Sven Strickroth · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

On 2019-04-09 09:34, Sven Strickroth wrote:
Show 15 quoted lines
> Am 09.04.2019 um 07:53 schrieb Torsten Bögershausen:
>>> Regression was introduced in commit
>>> 25d90d1cb72ce51407324259516843406142fe89.
>>
>> Was it ?
>> 25d90d1cb merged this commit:
>> 1cadad6f6 (junio/tb/use-common-win32-pathfuncs-on-cygwin)
>
> Yes, I copied the revision of the merge commit.
>
>> And, if I read that correctly,  1cadad6f6 does not change anything for MSVC.
>> And the problem with the missing/wrong path resolution was there before
>> 1cadad6f6 and after 1cadad6f6.
>
> That's not correct, it was correct before:
No, I wasn't aware that msvc.c include mingw.c - for whatever reason.
Show 5 quoted lines
> 1cadad6f6 removes mingw_offset_1st_component from mingw.c which is
> included by msvc.c. Then the in git-compat.h the new file
> "compat/win32/path-utils.h" is only included for __CYGWIN__ and
> __MINGW32__, here _MSC_VER is missing -> that's the regression.
>

OK, good. If possible, I would like to see this kind of information in the commit message. Thanks for cleaning up my mess.

Junio C Hamano· Apr 9, 2019, 16:46 UTC · re: Torsten Bögershausen · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

Torsten Bögershausen <tboegi@web.de> writes:
Show 10 quoted lines
>> 1cadad6f6 removes mingw_offset_1st_component from mingw.c which is
>> included by msvc.c. Then the in git-compat.h the new file
>> "compat/win32/path-utils.h" is only included for __CYGWIN__ and
>> __MINGW32__, here _MSC_VER is missing -> that's the regression.
>>
>
> OK, good.
> If possible, I would like to see this kind of information
> in the commit message.
> Thanks for cleaning up my mess.

Thanks, both. Should I wait for an update that fixes the proposed log message?

Torsten Bögershausen· Apr 10, 2019, 05:32 UTC · re: Junio C Hamano · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

On 2019-04-09 18:46, Junio C Hamano wrote:
Show 16 quoted lines
> Torsten Bögershausen <tboegi@web.de> writes:
>
>>> 1cadad6f6 removes mingw_offset_1st_component from mingw.c which is
>>> included by msvc.c. Then the in git-compat.h the new file
>>> "compat/win32/path-utils.h" is only included for __CYGWIN__ and
>>> __MINGW32__, here _MSC_VER is missing -> that's the regression.
>>>
>>
>> OK, good.
>> If possible, I would like to see this kind of information
>> in the commit message.
>> Thanks for cleaning up my mess.
>
> Thanks, both.  Should I wait for an update that fixes the proposed
> log message?
>
It seems that I haven't read all messages in my mailbox (or messages crossed).
The V2 patch describes the problem well and looks OK for me.
Junio C Hamano· Apr 12, 2019, 01:15 UTC · re: Torsten Bögershausen · lore

Re: [PATCH] Unbreak real_path on Windows for already absolute paths (with Visual Studio)

Torsten Bögershausen <tboegi@web.de> writes:
> It seems that I haven't read all messages in my mailbox (or messages crossed).
>
> The V2 patch describes the problem well and looks OK for me.

Yeah, I just re-read the log message with a fresh pair of eyes, and I think it is clear enough.

Thanks, both.

← back to recent threads