threads / discuss / 28028

[PATH 0/2] On Cygwin support both UNIX and DOS style path-names

Subject: [PATH 0/2] On Cygwin support both UNIX and DOS style path-names

## tl;dr

19 messages between Aug 5, 2011 and Aug 13, 2011.

replies: 18people: 6as markdown or json

Pascal Obry· Aug 5, 2011, 16:10 UTC · lore

This is the second version of this serie after Theo review. It includes the patch from Theo first and mine after.

Let me know if it looks ok. Thanks.
Pascal Obry· Aug 5, 2011, 16:10 UTC · re: Pascal Obry · lore

[PATCH 1/2] git-compat-util: add generic find_last_dir_sep that respects is_dir_sep

From: Theo Niessink <theo@taletn.com>

Move MinGW's find_last_dir_sep to git-compat-util.h, so it can also be used on other platforms that define is_dir_sep, e.g. Cygwin.

Signed-off-by: Theo Niessink <theo@taletn.com>
Acked-by: Pascal Obry <pascal@obry.net>
---
 compat/mingw.h    |    9 ---------
 git-compat-util.h |   12 ++++++++++++
 2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index ce9dd98..547568b 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -300,15 +300,6 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
 
 #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
 #define is_dir_sep(c) ((c) == '/' || (c) == '\\')
-static inline char *mingw_find_last_dir_sep(const char *path)
-{
-	char *ret = NULL;
-	for (; *path; ++path)
-		if (is_dir_sep(*path))
-			ret = (char *)path;
-	return ret;
-}
-#define find_last_dir_sep mingw_find_last_dir_sep
 #define PATH_SEP ';'
 #define PRIuMAX "I64u"
 
diff --git a/git-compat-util.h b/git-compat-util.h
index ddfbf77..c2c94cd 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -211,6 +211,18 @@ extern char *gitbasename(char *);
 #define has_dos_drive_prefix(path) 0
 #endif
 
+#if !defined(find_last_dir_sep) && defined(is_dir_sep)
+static inline char *compat_find_last_dir_sep(const char *path)
+{
+	char *ret = NULL;
+	for (; *path; ++path)
+		if (is_dir_sep(*path))
+			ret = (char *)path;
+	return ret;
+}
+#define find_last_dir_sep compat_find_last_dir_sep
+#endif
+
 #ifndef is_dir_sep
 #define is_dir_sep(c) ((c) == '/')
 #endif
-- 
1.7.6.404.g5d2fc
Pascal Obry· Aug 5, 2011, 16:10 UTC · re: Pascal Obry · lore

[PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

In fact Cygwin supports both, so make Git agree with this. The failing case is when a file is committed in a sub-dir of the repository using a log message from a file specified with a DOS style path-name. To reproduce:

   $ cd src
   $ git commit -F c:\tmp\log.txt file.c
   fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
   or directory.
Signed-off-by: Pascal Obry <pascal@obry.net>
---
 compat/cygwin.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/compat/cygwin.h b/compat/cygwin.h
index a3229f5..de9737c 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
 
 #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
 #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
+
+#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
+#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
-- 
1.7.6.404.g5d2fc
Erik Faye-Lund· Aug 5, 2011, 17:29 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

On Fri, Aug 5, 2011 at 6:10 PM, Pascal Obry <pascal@obry.net> wrote:
Show 9 quoted lines
> In fact Cygwin supports both, so make Git agree with this.
> The failing case is when a file is committed in a sub-dir of the
> repository using a log message from a file specified with a DOS
> style path-name. To reproduce:
>
>   $ cd src
>   $ git commit -F c:\tmp\log.txt file.c
>   fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>   or directory.

Cygwin is a unix-layer on top of Windows, designed to play by the POSIX-rules. So why would you want to support Windows-style paths on Cygwin?

If you want a Git that handles Windows paths, use Git for Windows...
Pascal Obry· Aug 5, 2011, 17:35 UTC · re: Erik Faye-Lund · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Le 05/08/2011 19:29, Erik Faye-Lund a écrit :
> Cygwin is a unix-layer on top of Windows, designed to play by the
> POSIX-rules. So why would you want to support Windows-style paths on
> Cygwin?
Because cygwin toolset does support \.
> If you want a Git that handles Windows paths, use Git for Windows...

Note that Windows is a special case as even the Win32 API does support \ and /, so every tool on Windows seems to handle nicely this. Why not Git, be it Cygwin/Git. If it does not break anything else.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Erik Faye-Lund· Aug 5, 2011, 17:39 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

On Fri, Aug 5, 2011 at 7:35 PM, Pascal Obry <pascal@obry.net> wrote:
Show 8 quoted lines
> Le 05/08/2011 19:29, Erik Faye-Lund a écrit :
>>
>> Cygwin is a unix-layer on top of Windows, designed to play by the
>> POSIX-rules. So why would you want to support Windows-style paths on
>> Cygwin?
>
> Because cygwin toolset does support \.
>

Are you saying that the built-in Cygwin tools (like ls etc) support Windows-style paths (C:\path\to\file)? If that is the case, I completely understand the desire to accept Windows-paths.

Show 5 quoted lines
>> If you want a Git that handles Windows paths, use Git for Windows...
>
> Note that Windows is a special case as even the Win32 API does support \ and
> /, so every tool on Windows seems to handle nicely this. Why not Git, be it
> Cygwin/Git. If it does not break anything else.

If the Cygwin-tools does not support drive-prefixes (i.e "C:\") but does support both slashes as path-separators, then I agree with the patch but not with the commit message.

Erik Faye-Lund· Aug 5, 2011, 17:51 UTC · re: Erik Faye-Lund · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

On Fri, Aug 5, 2011 at 7:39 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:
Show 24 quoted lines
> On Fri, Aug 5, 2011 at 7:35 PM, Pascal Obry <pascal@obry.net> wrote:
>> Le 05/08/2011 19:29, Erik Faye-Lund a écrit :
>>>
>>> Cygwin is a unix-layer on top of Windows, designed to play by the
>>> POSIX-rules. So why would you want to support Windows-style paths on
>>> Cygwin?
>>
>> Because cygwin toolset does support \.
>>
>
> Are you saying that the built-in Cygwin tools (like ls etc) support
> Windows-style paths (C:\path\to\file)? If that is the case, I
> completely understand the desire to accept Windows-paths.
>
>>> If you want a Git that handles Windows paths, use Git for Windows...
>>
>> Note that Windows is a special case as even the Win32 API does support \ and
>> /, so every tool on Windows seems to handle nicely this. Why not Git, be it
>> Cygwin/Git. If it does not break anything else.
>
> If the Cygwin-tools does not support drive-prefixes (i.e "C:\") but
> does support both slashes as path-separators, then I agree with the
> patch but not with the commit message.
>

correction: if that is the case, I agree with the is_dir_sep-part, but not the has_dos_drive_prefix-part of the patch (and also not the example from the commit message)

Pascal Obry· Aug 5, 2011, 18:39 UTC · re: Erik Faye-Lund · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Le 05/08/2011 19:39, Erik Faye-Lund a écrit :
> Are you saying that the built-in Cygwin tools (like ls etc) support
> Windows-style paths (C:\path\to\file)? If that is the case, I
> completely understand the desire to accept Windows-paths.
Exactly.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Ramsay Jones· Aug 9, 2011, 17:30 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Pascal Obry wrote:
Show 6 quoted lines
> Le 05/08/2011 19:29, Erik Faye-Lund a écrit :
>> Cygwin is a unix-layer on top of Windows, designed to play by the
>> POSIX-rules. So why would you want to support Windows-style paths on
>> Cygwin?
> 
> Because cygwin toolset does support \.
Hmm, if you don't mind escaping it in bash all the time!
Show 6 quoted lines
> 
>> If you want a Git that handles Windows paths, use Git for Windows...
> 
> Note that Windows is a special case as even the Win32 API does support \ 
> and /, so every tool on Windows seems to handle nicely this. Why not 
> Git, be it Cygwin/Git. If it does not break anything else.
Hmm, I wouldn't be too sure of that, either ...

ATB, Ramsay Jones

Ramsay Jones· Aug 9, 2011, 17:26 UTC · re: Erik Faye-Lund · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Erik Faye-Lund wrote:
Show 16 quoted lines
> On Fri, Aug 5, 2011 at 6:10 PM, Pascal Obry <pascal@obry.net> wrote:
>> In fact Cygwin supports both, so make Git agree with this.
>> The failing case is when a file is committed in a sub-dir of the
>> repository using a log message from a file specified with a DOS
>> style path-name. To reproduce:
>>
>>   $ cd src
>>   $ git commit -F c:\tmp\log.txt file.c
>>   fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>>   or directory.
> 
> Cygwin is a unix-layer on top of Windows, designed to play by the
> POSIX-rules. So why would you want to support Windows-style paths on
> Cygwin?
> 
> If you want a Git that handles Windows paths, use Git for Windows...

Indeed, I have to agree. This takes the cygwin port in the wrong direction ...

ATB, Ramsay Jones

Junio C Hamano· Aug 5, 2011, 17:48 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Pascal Obry <pascal@obry.net> writes:
Show 26 quoted lines
> In fact Cygwin supports both, so make Git agree with this.
> The failing case is when a file is committed in a sub-dir of the
> repository using a log message from a file specified with a DOS
> style path-name. To reproduce:
>
>    $ cd src
>    $ git commit -F c:\tmp\log.txt file.c
>    fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>    or directory.
>
> Signed-off-by: Pascal Obry <pascal@obry.net>
> ---
>  compat/cygwin.h |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/compat/cygwin.h b/compat/cygwin.h
> index a3229f5..de9737c 100644
> --- a/compat/cygwin.h
> +++ b/compat/cygwin.h
> @@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
>  
>  #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
>  #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
> +
> +#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
> +#define is_dir_sep(c) ((c) == '/' || (c) == '\\')

I wonder if these two that are the same as mingw should further be consolidated into one implementation, something like below.

Note that I am just wondering, not suggesting, without knowing which is better.

 compat/cygwin.h   |    5 ++---
 compat/mingw.h    |    3 +--
 git-compat-util.h |   11 ++++-------
 3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/compat/cygwin.h b/compat/cygwin.h
index de9737c..ef0889b 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -1,12 +1,11 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#define DOS_STYLE_DIR_SEP 1
+
 typedef int (*stat_fn_t)(const char*, struct stat*);
 extern stat_fn_t cygwin_stat_fn;
 extern stat_fn_t cygwin_lstat_fn;
 
 #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
 #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
-
-#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
-#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
diff --git a/compat/mingw.h b/compat/mingw.h
index 547568b..26ca0ef 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -298,8 +298,7 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
  * git specific compatibility
  */
 
-#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
-#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
+#define DOS_STYLE_DIR_SEP 1
 #define PATH_SEP ';'
 #define PRIuMAX "I64u"
 
diff --git a/git-compat-util.h b/git-compat-util.h
index c2c94cd..133f331 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -211,7 +211,9 @@ extern char *gitbasename(char *);
 #define has_dos_drive_prefix(path) 0
 #endif
 
-#if !defined(find_last_dir_sep) && defined(is_dir_sep)
+#if defined(DOS_STYLE_DIR_SEP)
+#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
+#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
 static inline char *compat_find_last_dir_sep(const char *path)
 {
 	char *ret = NULL;
@@ -221,13 +223,8 @@ static inline char *compat_find_last_dir_sep(const char *path)
 	return ret;
 }
 #define find_last_dir_sep compat_find_last_dir_sep
-#endif
-
-#ifndef is_dir_sep
+#else
 #define is_dir_sep(c) ((c) == '/')
-#endif
-
-#ifndef find_last_dir_sep
 #define find_last_dir_sep(path) strrchr(path, '/')
 #endif
 
Erik Faye-Lund· Aug 5, 2011, 17:58 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

On Fri, Aug 5, 2011 at 7:48 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 34 quoted lines
> Pascal Obry <pascal@obry.net> writes:
>
>> In fact Cygwin supports both, so make Git agree with this.
>> The failing case is when a file is committed in a sub-dir of the
>> repository using a log message from a file specified with a DOS
>> style path-name. To reproduce:
>>
>>    $ cd src
>>    $ git commit -F c:\tmp\log.txt file.c
>>    fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>>    or directory.
>>
>> Signed-off-by: Pascal Obry <pascal@obry.net>
>> ---
>>  compat/cygwin.h |    3 +++
>>  1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/compat/cygwin.h b/compat/cygwin.h
>> index a3229f5..de9737c 100644
>> --- a/compat/cygwin.h
>> +++ b/compat/cygwin.h
>> @@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
>>
>>  #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
>>  #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
>> +
>> +#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
>> +#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
>
> I wonder if these two that are the same as mingw should further be
> consolidated into one implementation, something like below.
>
> Note that I am just wondering, not suggesting, without knowing which is
> better.

IMO this becomes a bit hard to read as you have to ping-pong between sources to understand exactly what that flag does. We have compat/win32.h, perhaps we should move the macros there and include it from both compat/mingw.h and compat/cygwin.h instead (given that we're going to do this, of course)?

Pascal Obry· Aug 6, 2011, 07:01 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Le 05/08/2011 19:48, Junio C Hamano a écrit :
> I wonder if these two that are the same as mingw should further be
> consolidated into one implementation, something like below.
Fine with me.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Ramsay Jones· Aug 9, 2011, 17:24 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Pascal Obry wrote:
Show 9 quoted lines
> In fact Cygwin supports both, so make Git agree with this.
> The failing case is when a file is committed in a sub-dir of the
> repository using a log message from a file specified with a DOS
> style path-name. To reproduce:
> 
>    $ cd src
>    $ git commit -F c:\tmp\log.txt file.c
>    fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>    or directory.
Hmm, are you using bash or cmd.exe? Using bash I get the following:
    $ cd src
    $ git commut -F c:\tmp\log.txt file.c
    fatal: could not read file 'src/c:tmplog.txt': No such file or directory
    $ 
Which is what I would expect of (any) posix shell, viz:
    $ ls c:\
    > ^C
    $ ls c:\\
    AUTOEXEC.BAT*            NTDETECT.COM*               WATCOM/       msysgit/
    CMPNENTS/                Program Files/              WINDOWS/      msysgit-old/
    CONFIG.SYS*              RECYCLER/                   boot.ini*     ntldr*
    Documents and Settings/  SUPPORT/                    cygwin/       pagefile.sys
    I386/                    SWSTAMP.TXT*                cygwintemp/   ssl/
    IO.SYS*                  System Volume Information/  dm/           uname/
    MSDOS.SYS*               TOOLSCD/                    dm840/        zlib/
    MSOCache/                VALUEADD/                   hiberfil.sys
    $ 

If you want to use cmd.exe as your shell, I suspect msysGit (Git For Windows) may be a better fit.

ATB, Ramsay Jones

Pascal Obry· Aug 9, 2011, 20:38 UTC · re: Ramsay Jones · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Le 09/08/2011 19:24, Ramsay Jones a écrit :
Show 12 quoted lines
> Pascal Obry wrote:
>> In fact Cygwin supports both, so make Git agree with this.
>> The failing case is when a file is committed in a sub-dir of the
>> repository using a log message from a file specified with a DOS
>> style path-name. To reproduce:
>>
>>     $ cd src
>>     $ git commit -F c:\tmp\log.txt file.c
>>     fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>>     or directory.
>
> Hmm, are you using bash or cmd.exe? Using bash I get the following:
bash.
Show 19 quoted lines
>
>      $ cd src
>      $ git commut -F c:\tmp\log.txt file.c
>      fatal: could not read file 'src/c:tmplog.txt': No such file or directory
>      $
>
> Which is what I would expect of (any) posix shell, viz:
>
>      $ ls c:\
>      >  ^C
>      $ ls c:\\
>      AUTOEXEC.BAT*            NTDETECT.COM*               WATCOM/       msysgit/
>      CMPNENTS/                Program Files/              WINDOWS/      msysgit-old/
>      CONFIG.SYS*              RECYCLER/                   boot.ini*     ntldr*
>      Documents and Settings/  SUPPORT/                    cygwin/       pagefile.sys
>      I386/                    SWSTAMP.TXT*                cygwintemp/   ssl/
>      IO.SYS*                  System Volume Information/  dm/           uname/
>      MSDOS.SYS*               TOOLSCD/                    dm840/        zlib/
>      MSOCache/                VALUEADD/                   hiberfil.sys

Exactly, \\ this is what I have used and this is the bug. Cygwin supports ls c:\\ so should Cygwin/Git. My quoted example was missing the escape \.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Ramsay Jones· Aug 11, 2011, 20:35 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Pascal Obry wrote:
Show 14 quoted lines
> Le 09/08/2011 19:24, Ramsay Jones a écrit :
>> Pascal Obry wrote:
>>> In fact Cygwin supports both, so make Git agree with this.
>>> The failing case is when a file is committed in a sub-dir of the
>>> repository using a log message from a file specified with a DOS
>>> style path-name. To reproduce:
>>>
>>>     $ cd src
>>>     $ git commit -F c:\tmp\log.txt file.c
>>>     fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>>>     or directory.
>> Hmm, are you using bash or cmd.exe? Using bash I get the following:
> 
> bash.

Ah, OK. The example in your commit message looked odd (ie incorrect) which made me think that you were probably using cnd.exe, so ...

Show 22 quoted lines
>>      $ cd src
>>      $ git commut -F c:\tmp\log.txt file.c
>>      fatal: could not read file 'src/c:tmplog.txt': No such file or directory
>>      $
>>
>> Which is what I would expect of (any) posix shell, viz:
>>
>>      $ ls c:\
>>      >  ^C
>>      $ ls c:\\
>>      AUTOEXEC.BAT*            NTDETECT.COM*               WATCOM/       msysgit/
>>      CMPNENTS/                Program Files/              WINDOWS/      msysgit-old/
>>      CONFIG.SYS*              RECYCLER/                   boot.ini*     ntldr*
>>      Documents and Settings/  SUPPORT/                    cygwin/       pagefile.sys
>>      I386/                    SWSTAMP.TXT*                cygwintemp/   ssl/
>>      IO.SYS*                  System Volume Information/  dm/           uname/
>>      MSDOS.SYS*               TOOLSCD/                    dm840/        zlib/
>>      MSOCache/                VALUEADD/                   hiberfil.sys
> 
> Exactly, \\ this is what I have used and this is the bug. Cygwin 
> supports ls c:\\ so should Cygwin/Git. My quoted example was missing the 
> escape \.
 ... could you please correct your commit message. Thanks!

ATB, Ramsay Jones

Pascal Obry· Aug 13, 2011, 17:34 UTC · re: Ramsay Jones · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Le 11/08/2011 22:35, Ramsay Jones a écrit :
>   ... could you please correct your commit message. Thanks!
Done, thanks for your review.
Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Vijay Lakshminarayanan· Aug 10, 2011, 02:44 UTC · re: Ramsay Jones · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
Show 32 quoted lines
> Pascal Obry wrote:
>> In fact Cygwin supports both, so make Git agree with this.
>> The failing case is when a file is committed in a sub-dir of the
>> repository using a log message from a file specified with a DOS
>> style path-name. To reproduce:
>> 
>>    $ cd src
>>    $ git commit -F c:\tmp\log.txt file.c
>>    fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>>    or directory.
>
> Hmm, are you using bash or cmd.exe? Using bash I get the following:
>
>     $ cd src
>     $ git commut -F c:\tmp\log.txt file.c
>     fatal: could not read file 'src/c:tmplog.txt': No such file or directory
>     $ 
>
> Which is what I would expect of (any) posix shell, viz:
>
>     $ ls c:\
>     > ^C
>     $ ls c:\\
>     AUTOEXEC.BAT*            NTDETECT.COM*               WATCOM/       msysgit/
>     CMPNENTS/                Program Files/              WINDOWS/      msysgit-old/
>     CONFIG.SYS*              RECYCLER/                   boot.ini*     ntldr*
>     Documents and Settings/  SUPPORT/                    cygwin/       pagefile.sys
>     I386/                    SWSTAMP.TXT*                cygwintemp/   ssl/
>     IO.SYS*                  System Volume Information/  dm/           uname/
>     MSDOS.SYS*               TOOLSCD/                    dm840/        zlib/
>     MSOCache/                VALUEADD/                   hiberfil.sys
>     $ 

FWIW, I use git on Cygwin and it works quite well. Cygwin supports Windows paths when quoted. So

$ ls 'C:\Users\vijay\Desktop'

works as expected. This is very useful when you're copying paths from, say, Windows Explorer, to Cygwin.

Show 7 quoted lines
> ATB,
> Ramsay Jones
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Cheers
~vijay

Gnus should be more complicated.
Johannes Sixt· Aug 9, 2011, 19:47 UTC · re: Pascal Obry · lore

Re: [PATCH 2/2] On Cygwin support both UNIX and DOS style path-names

Am 05.08.2011 18:10, schrieb Pascal Obry:
Show 9 quoted lines
> In fact Cygwin supports both, so make Git agree with this.
> The failing case is when a file is committed in a sub-dir of the
> repository using a log message from a file specified with a DOS
> style path-name. To reproduce:
> 
>    $ cd src
>    $ git commit -F c:\tmp\log.txt file.c
>    fatal: could not read log file 'src/c:\tmp\log.txt': No such file \
>    or directory.
Do you also want to support this:
     $ git add src\file.c
i.e., backslash in pathspec? Then you need more than this:
> +#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
> +#define is_dir_sep(c) ((c) == '/' || (c) == '\\')

In particular, you have to enable backslash processing in setup.c:prefix_filename(), but then you lose the ability to escape special characters with the backslash.

-- Hannes

← back to recent threads