public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* git and absolute Windows-style paths
@ 2016-04-19 21:00 silverwind
  2016-04-19 21:58 ` Marco Atzeri
  2016-04-20  0:49 ` Bill Smith
  0 siblings, 2 replies; 18+ messages in thread
From: silverwind @ 2016-04-19 21:00 UTC (permalink / raw)
  To: cygwin

Hey,

I noticed that Cygwin's git does not seem to correctly process 
Windows-style paths in at least v2.7.4 and v2.8.1. It may have worked 
before, but I'm not totally certain.

Interestingly, a command like "git add" still sets an 0 exit code 
despite the apparent failure. Could it be that some effort to correct 
the path is attempted, but it failed?

$ mkdir /cygdrive/c/test
$ cd /cygdrive/c/test
$ git init
$ touch file
$ git add C:\\test\\file         <-- this fails despite exit code 0
$ git status                     <-- shows no changes
$ git add /cygdrive/c/test/file  <-- this works
$ git status                     <-- correctly shows "new file"

Regards
Roman

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-19 21:00 git and absolute Windows-style paths silverwind
@ 2016-04-19 21:58 ` Marco Atzeri
  2016-04-19 22:28   ` Ken Brown
  2016-04-20  0:49 ` Bill Smith
  1 sibling, 1 reply; 18+ messages in thread
From: Marco Atzeri @ 2016-04-19 21:58 UTC (permalink / raw)
  To: cygwin

On 19/04/2016 22:34, silverwind wrote:
> Hey,
>
> I noticed that Cygwin's git does not seem to correctly process
> Windows-style paths in at least v2.7.4 and v2.8.1. It may have worked
> before, but I'm not totally certain.

don't assume cygwin programs are able to process windows path.
Most don't. Use Posix paths



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-19 21:58 ` Marco Atzeri
@ 2016-04-19 22:28   ` Ken Brown
  2016-04-20 10:28     ` Adam Dinwoodie
  0 siblings, 1 reply; 18+ messages in thread
From: Ken Brown @ 2016-04-19 22:28 UTC (permalink / raw)
  To: cygwin

On 4/19/2016 5:31 PM, Marco Atzeri wrote:
> On 19/04/2016 22:34, silverwind wrote:
>> Hey,
>>
>> I noticed that Cygwin's git does not seem to correctly process
>> Windows-style paths in at least v2.7.4 and v2.8.1. It may have worked
>> before, but I'm not totally certain.
>
> don't assume cygwin programs are able to process windows path.
> Most don't. Use Posix paths

But I think the OP is correct in pointing out that git should have given 
an error, as it does when a Posix path points to a non-existent file:

$ git add foo
fatal: pathspec 'foo' did not match any files

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: git and absolute Windows-style paths
  2016-04-19 21:00 git and absolute Windows-style paths silverwind
  2016-04-19 21:58 ` Marco Atzeri
@ 2016-04-20  0:49 ` Bill Smith
  2016-04-20 15:52   ` silverwind
  1 sibling, 1 reply; 18+ messages in thread
From: Bill Smith @ 2016-04-20  0:49 UTC (permalink / raw)
  To: silverwind, cygwin



> $ git add C:\\test\\file         <-- this fails despite exit code 0
[Bill Smith] 
Does it work if you do:

git add c:/test/file

We use the mixed mode paths extensively with Cygwin in our environment and it works well.  We have the issue of having to work with non-Cygwin aware Windows programs.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-19 22:28   ` Ken Brown
@ 2016-04-20 10:28     ` Adam Dinwoodie
  0 siblings, 0 replies; 18+ messages in thread
From: Adam Dinwoodie @ 2016-04-20 10:28 UTC (permalink / raw)
  To: cygwin

On Tue, Apr 19, 2016 at 05:58:18PM -0400, Ken Brown wrote:
> On 4/19/2016 5:31 PM, Marco Atzeri wrote:
> >On 19/04/2016 22:34, silverwind wrote:
> >>Hey,
> >>
> >>I noticed that Cygwin's git does not seem to correctly process
> >>Windows-style paths in at least v2.7.4 and v2.8.1. It may have worked
> >>before, but I'm not totally certain.
> >
> >don't assume cygwin programs are able to process windows path.
> >Most don't. Use Posix paths
> 
> But I think the OP is correct in pointing out that git should have
> given an error, as it does when a Posix path points to a
> non-existent file:
> 
> $ git add foo
> fatal: pathspec 'foo' did not match any files

I wouldn't expect Windows-style paths to work, but I agree that I'd
expect them to error out rather than silently fail.  I can't immediately
see what's going wrong, so I'm going to report this upstream.

Some data points, from some quick experimentation:

- `git add 'c:\tmp\file'` silently fails to add `file` if it exists.
- `git add 'c:\tmp\file'` correctly errors out if `file` doesn't exist.
- `git add 'subdir\file'` (i.e. using relative paths with back-slashes)
  has the same behaviour.
- `git add 'c:/tmp/file'` also shows the same behaviour.

Adam

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20  0:49 ` Bill Smith
@ 2016-04-20 15:52   ` silverwind
  2016-04-20 16:06     ` Eliot Moss
  0 siblings, 1 reply; 18+ messages in thread
From: silverwind @ 2016-04-20 15:52 UTC (permalink / raw)
  To: cygwin

Hey,

> Does it work if you do:
>
> git add c:/test/file

Nope, won't work either. No file is added, exit code 0 is given.

 > I can't immediately see what's going wrong, so I'm going to report 
this upstream.

Thanks. I came upon this issue through npm which is using these Windows 
paths for certain git operations. Unfortunately, The npm team is very 
reluctant when it comes to merging Cygwin-specific patches, so chances 
of landing a fix on their side are rather slim.

Is there a public repository for the git package used by Cygwin?

Regards,
Roman

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 15:52   ` silverwind
@ 2016-04-20 16:06     ` Eliot Moss
  2016-04-20 16:15       ` Brian Clifton
  2016-04-20 16:46       ` silverwind
  0 siblings, 2 replies; 18+ messages in thread
From: Eliot Moss @ 2016-04-20 16:06 UTC (permalink / raw)
  To: cygwin

On 4/20/2016 11:44 AM, silverwind wrote:
> Hey,
>
>> Does it work if you do:
>>
>> git add c:/test/file
>
> Nope, won't work either. No file is added, exit code 0 is given.
>
>  > I can't immediately see what's going wrong, so I'm going to report this upstream.
>
> Thanks. I came upon this issue through npm which is using these Windows paths for certain git
> operations. Unfortunately, The npm team is very reluctant when it comes to merging Cygwin-specific
> patches, so chances of landing a fix on their side are rather slim.
>
> Is there a public repository for the git package used by Cygwin?

I think that tackling this with a script/function is a better approach ...

Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 16:06     ` Eliot Moss
@ 2016-04-20 16:15       ` Brian Clifton
  2016-04-20 18:18         ` Ernie Rael
  2016-04-20 20:39         ` Eliot Moss
  2016-04-20 16:46       ` silverwind
  1 sibling, 2 replies; 18+ messages in thread
From: Brian Clifton @ 2016-04-20 16:15 UTC (permalink / raw)
  To: cygwin

I agree completely-

Faking out git by wrapping it as a function in your .bashrc would be an ideal approach.  I was the person championing that PR which got rejected, unfortunately. The NPM folks were recommending to use mingw which *is* supported... but I haven't seen any updates to that project since 2013... and I prefer the approach Cygwin takes :)

Eliot, I would be all about taking you up on fixing that psuedo-code example I shared earlier. I have a lot to learn about shell scripting and while I am sure I can figure it out, having help would be extremely appreciated :)

The example I shared in my intro thread:
#####
function git {
    for var in "$@"
    do
        if [[ $var == *":\\"* ]]; then
            $var="$(cygpath $var)" #this doesn't work, but the idea is to do something like this
        fi
    done
    command git "$@"
}
#####
________________________________________
From: cygwin-owner@cygwin.com <cygwin-owner@cygwin.com> on behalf of Eliot Moss <moss@cs.umass.edu>
Sent: Wednesday, April 20, 2016 8:52 AM
To: cygwin@cygwin.com
Subject: Re: git and absolute Windows-style paths

On 4/20/2016 11:44 AM, silverwind wrote:
> Hey,
>
>> Does it work if you do:
>>
>> git add c:/test/file
>
> Nope, won't work either. No file is added, exit code 0 is given.
>
>  > I can't immediately see what's going wrong, so I'm going to report this upstream.
>
> Thanks. I came upon this issue through npm which is using these Windows paths for certain git
> operations. Unfortunately, The npm team is very reluctant when it comes to merging Cygwin-specific
> patches, so chances of landing a fix on their side are rather slim.
>
> Is there a public repository for the git package used by Cygwin?

I think that tackling this with a script/function is a better approach ...

Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 16:06     ` Eliot Moss
  2016-04-20 16:15       ` Brian Clifton
@ 2016-04-20 16:46       ` silverwind
  2016-04-20 16:56         ` Adam Dinwoodie
  1 sibling, 1 reply; 18+ messages in thread
From: silverwind @ 2016-04-20 16:46 UTC (permalink / raw)
  To: cygwin

Hey,

> I think that tackling this with a script/function is a better approach ...

That's seems like a bandaid solution from which the general user base 
would not be able to profit. I think a floating patch to Cygwin's git 
package would be more appropriate, unless it can be addressed in 
Cygwin's system calls (which I'm sure has been attempted).

Why can I

   cat c:\\file.txt

but can't

   git add c:\\file.txt

? Where is this path normalization magic happening?

Regards,
Roman

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 16:46       ` silverwind
@ 2016-04-20 16:56         ` Adam Dinwoodie
  0 siblings, 0 replies; 18+ messages in thread
From: Adam Dinwoodie @ 2016-04-20 16:56 UTC (permalink / raw)
  To: cygwin

On Wed, Apr 20, 2016 at 05:44:47PM +0200, silverwind wrote:
> > I can't immediately see what's going wrong, so I'm going to report
> this upstream.
> 
> Thanks. I came upon this issue through npm which is using these
> Windows paths for certain git operations. Unfortunately, The npm
> team is very reluctant when it comes to merging Cygwin-specific
> patches, so chances of landing a fix on their side are rather slim.
> 
> Is there a public repository for the git package used by Cygwin?

The main Git repository[0] includes a bunch of Cygwin specific code
already, and I maintain a repository of the packaging paraphernalia[1]
which includes a couple of patches that aren't yet in the upstream code.

[0]: https://git.kernel.org/cgit/git/git.git/
[1]: http://github.com/me-and/Cygwin-Git

On Wed, Apr 20, 2016 at 06:21:53PM +0200, silverwind wrote:
> I think a floating patch to Cygwin's git 
> package would be more appropriate, unless it can be addressed in 
> Cygwin's system calls (which I'm sure has been attempted).

As the Git maintainer for Cygwin, I'm not willing to maintain a
downstream patch to make Cygwin Git handle Windows-style paths, and I
don't think there's much chance of one being accepted into the upstream
Git source code (although you're obviously welcome to try getting such a
patch accepted).

If you need to be able to pass Windows-style paths to Cygwin
applications, you should write a wrapper function or script that calls
`cygpath` to do the conversion.  Anything else is liable to work
intermittently at best; Cygwin applications in general expect
POSIX-style paths, given the aim of the Cygwin project is to provide a
POSIX-like environment.

Adam

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 16:15       ` Brian Clifton
@ 2016-04-20 18:18         ` Ernie Rael
  2016-04-20 20:39         ` Eliot Moss
  1 sibling, 0 replies; 18+ messages in thread
From: Ernie Rael @ 2016-04-20 18:18 UTC (permalink / raw)
  To: cygwin

On 4/20/2016 9:10 AM, Brian Clifton wrote:
> I agree completely-
>
> Faking out git by wrapping it as a function in your .bashrc would be an ideal approach.  I was the person championing that PR which got rejected, unfortunately. The NPM folks were recommending to use mingw which *is* supported... but I haven't seen any updates to that project since 2013... and I prefer the approach Cygwin takes :)
>
> Eliot, I would be all about taking you up on fixing that psuedo-code example I shared earlier. I have a lot to learn about shell scripting and while I am sure I can figure it out, having help would be extremely appreciated :)
>
> The example I shared in my intro thread:
> #####
> function git {
>      for var in "$@"
>      do
>          if [[ $var == *":\\"* ]]; then
>              $var="$(cygpath $var)" #this doesn't work, but the idea is to do something like this
>          fi
>      done
>      command git "$@"
> }
> #####

This extract from a bash function, using an array assignment, might be 
of interest.

       IFS=$'\n'
       args=($(cygpath -m -- "$@"))
       IFS=$' \t\n'
       gvim "${args[@]}"

> ________________________________________
> From: cygwin-owner@cygwin.com <cygwin-owner@cygwin.com> on behalf of Eliot Moss <moss@cs.umass.edu>
> Sent: Wednesday, April 20, 2016 8:52 AM
> To: cygwin@cygwin.com
> Subject: Re: git and absolute Windows-style paths
>
> On 4/20/2016 11:44 AM, silverwind wrote:
>> Hey,
>>
>>> Does it work if you do:
>>>
>>> git add c:/test/file
>> Nope, won't work either. No file is added, exit code 0 is given.
>>
>>   > I can't immediately see what's going wrong, so I'm going to report this upstream.
>>
>> Thanks. I came upon this issue through npm which is using these Windows paths for certain git
>> operations. Unfortunately, The npm team is very reluctant when it comes to merging Cygwin-specific
>> patches, so chances of landing a fix on their side are rather slim.
>>
>> Is there a public repository for the git package used by Cygwin?
> I think that tackling this with a script/function is a better approach ...
>
> Eliot Moss
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>
>


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 16:15       ` Brian Clifton
  2016-04-20 18:18         ` Ernie Rael
@ 2016-04-20 20:39         ` Eliot Moss
  2016-04-20 21:17           ` Adam Dinwoodie
  2016-04-20 23:40           ` Ernie Rael
  1 sibling, 2 replies; 18+ messages in thread
From: Eliot Moss @ 2016-04-20 20:39 UTC (permalink / raw)
  To: cygwin

I think this will do it:

function git {
   declare -a ARGS
   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
   command git "${ARGS[@]}"
}

The reason this is a little more complicated than some other approaches
might be is that it will also work for arguments that have space, e.g.,

git add "C:/My Documents/foo.doc"

Regards -- Eliot

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 20:39         ` Eliot Moss
@ 2016-04-20 21:17           ` Adam Dinwoodie
  2016-04-21 19:50             ` Andrey Repin
  2016-04-20 23:40           ` Ernie Rael
  1 sibling, 1 reply; 18+ messages in thread
From: Adam Dinwoodie @ 2016-04-20 21:17 UTC (permalink / raw)
  To: cygwin

On Wed, Apr 20, 2016 at 04:37:34PM -0400, Eliot Moss wrote:
> I think this will do it:
> 
> function git {
>   declare -a ARGS
>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>   command git "${ARGS[@]}"
> }
> 
> The reason this is a little more complicated than some other approaches
> might be is that it will also work for arguments that have space, e.g.,
> 
> git add "C:/My Documents/foo.doc"

For a marginally simpler, or at least shorter, version, use `for n; do
...` rather than `for n in "$@"; do` -- Bash loops over positional
arguments by default if you don't specify a list with `in`.

Perfect for confusing anyone else (or indeed yourself at some point in
the future) who isn't familiar with the many, many idiosyncrasies of
shell languages.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 20:39         ` Eliot Moss
  2016-04-20 21:17           ` Adam Dinwoodie
@ 2016-04-20 23:40           ` Ernie Rael
  2016-04-21  0:14             ` Eliot Moss
  1 sibling, 1 reply; 18+ messages in thread
From: Ernie Rael @ 2016-04-20 23:40 UTC (permalink / raw)
  To: cygwin

On 4/20/2016 1:37 PM, Eliot Moss wrote:
> I think this will do it:
>
> function git {
>   declare -a ARGS
>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>   command git "${ARGS[@]}"
> }
>
> The reason this is a little more complicated than some other approaches
> might be is that it will also work for arguments that have space, e.g.,
>
> git add "C:/My Documents/foo.doc"

Notice that
    IFS=$'\n'; args=($(cygpath -m -- "$@")); IFS=$' \t\n'
also handles arguments with spaces. You don't need the shell for loop.

-ernie
>
> Regards -- Eliot
>
> -- 
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>
>


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 23:40           ` Ernie Rael
@ 2016-04-21  0:14             ` Eliot Moss
  2016-04-21 15:19               ` Ray Donnelly
  0 siblings, 1 reply; 18+ messages in thread
From: Eliot Moss @ 2016-04-21  0:14 UTC (permalink / raw)
  To: cygwin

On 4/20/2016 7:14 PM, Ernie Rael wrote:
> On 4/20/2016 1:37 PM, Eliot Moss wrote:
>> I think this will do it:
>>
>> function git {
>>   declare -a ARGS
>>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>>   command git "${ARGS[@]}"
>> }
>>
>> The reason this is a little more complicated than some other approaches
>> might be is that it will also work for arguments that have space, e.g.,
>>
>> git add "C:/My Documents/foo.doc"
>
> Notice that
>     IFS=$'\n'; args=($(cygpath -m -- "$@")); IFS=$' \t\n'
> also handles arguments with spaces. You don't need the shell for loop.

Ok ... but I would save the previous value of IFS and restore it -- never
know what a user might be using there ...

Best -- E

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-21  0:14             ` Eliot Moss
@ 2016-04-21 15:19               ` Ray Donnelly
  2016-04-21 16:01                 ` Ray Donnelly
  0 siblings, 1 reply; 18+ messages in thread
From: Ray Donnelly @ 2016-04-21 15:19 UTC (permalink / raw)
  To: cygwin

Here's a patch for git 2.8.1 that I wrote for MSYS2 to address the
same issue. Because I'd read this thread before I started working on
it (and generally since it's good to) I kept it in mind to make it
work for Cygwin in-case you wanted to use it:

https://raw.githubusercontent.com/Alexpux/MSYS2-packages/6b7aceea4ad2e5bd28143a2de8c4a0d7453013dc/git/git-2.8.1-Cygwin-Allow-DOS-paths.patch

I'm running the test-suite now which takes an age, but I don't see any
problems with it so far. I didn't add any tests covering using DOS
paths though. I've tested it with git add and clone with DOS relative
and absolute paths.

Best regards,

Ray.

On Thu, Apr 21, 2016 at 12:40 AM, Eliot Moss <moss@cs.umass.edu> wrote:
> On 4/20/2016 7:14 PM, Ernie Rael wrote:
>>
>> On 4/20/2016 1:37 PM, Eliot Moss wrote:
>>>
>>> I think this will do it:
>>>
>>> function git {
>>>   declare -a ARGS
>>>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>>>   command git "${ARGS[@]}"
>>> }
>>>
>>> The reason this is a little more complicated than some other approaches
>>> might be is that it will also work for arguments that have space, e.g.,
>>>
>>> git add "C:/My Documents/foo.doc"
>>
>>
>> Notice that
>>     IFS=$'\n'; args=($(cygpath -m -- "$@")); IFS=$' \t\n'
>> also handles arguments with spaces. You don't need the shell for loop.
>
>
> Ok ... but I would save the previous value of IFS and restore it -- never
> know what a user might be using there ...
>
> Best -- E
>
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-21 15:19               ` Ray Donnelly
@ 2016-04-21 16:01                 ` Ray Donnelly
  0 siblings, 0 replies; 18+ messages in thread
From: Ray Donnelly @ 2016-04-21 16:01 UTC (permalink / raw)
  To: cygwin

On Thu, Apr 21, 2016 at 2:11 PM, Ray Donnelly <mingw.android@gmail.com> wrote:
> Here's a patch for git 2.8.1 that I wrote for MSYS2 to address the
> same issue. Because I'd read this thread before I started working on
> it (and generally since it's good to) I kept it in mind to make it
> work for Cygwin in-case you wanted to use it:
>
> https://raw.githubusercontent.com/Alexpux/MSYS2-packages/6b7aceea4ad2e5bd28143a2de8c4a0d7453013dc/git/git-2.8.1-Cygwin-Allow-DOS-paths.patch
>
> I'm running the test-suite now which takes an age, but I don't see any
> problems with it so far. I didn't add any tests covering using DOS
> paths though. I've tested it with git add and clone with DOS relative
> and absolute paths.

FYI, the test results were the same before and after this patch.

>
> Best regards,
>
> Ray.
>
> On Thu, Apr 21, 2016 at 12:40 AM, Eliot Moss <moss@cs.umass.edu> wrote:
>> On 4/20/2016 7:14 PM, Ernie Rael wrote:
>>>
>>> On 4/20/2016 1:37 PM, Eliot Moss wrote:
>>>>
>>>> I think this will do it:
>>>>
>>>> function git {
>>>>   declare -a ARGS
>>>>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>>>>   command git "${ARGS[@]}"
>>>> }
>>>>
>>>> The reason this is a little more complicated than some other approaches
>>>> might be is that it will also work for arguments that have space, e.g.,
>>>>
>>>> git add "C:/My Documents/foo.doc"
>>>
>>>
>>> Notice that
>>>     IFS=$'\n'; args=($(cygpath -m -- "$@")); IFS=$' \t\n'
>>> also handles arguments with spaces. You don't need the shell for loop.
>>
>>
>> Ok ... but I would save the previous value of IFS and restore it -- never
>> know what a user might be using there ...
>>
>> Best -- E
>>
>>
>> --
>> Problem reports:       http://cygwin.com/problems.html
>> FAQ:                   http://cygwin.com/faq/
>> Documentation:         http://cygwin.com/docs.html
>> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: git and absolute Windows-style paths
  2016-04-20 21:17           ` Adam Dinwoodie
@ 2016-04-21 19:50             ` Andrey Repin
  0 siblings, 0 replies; 18+ messages in thread
From: Andrey Repin @ 2016-04-21 19:50 UTC (permalink / raw)
  To: Adam Dinwoodie, cygwin

Greetings, Adam Dinwoodie!

> On Wed, Apr 20, 2016 at 04:37:34PM -0400, Eliot Moss wrote:
>> I think this will do it:
>> 
>> function git {
>>   declare -a ARGS
>>   for n in "$@" ; do ARGS+=("$(cygpath -u -- "${n}")") ; done
>>   command git "${ARGS[@]}"
>> }
>> 
>> The reason this is a little more complicated than some other approaches
>> might be is that it will also work for arguments that have space, e.g.,
>> 
>> git add "C:/My Documents/foo.doc"

> For a marginally simpler, or at least shorter, version, use `for n; do
> ...` rather than `for n in "$@"; do` -- Bash loops over positional
> arguments by default if you don't specify a list with `in`.

> Perfect for confusing anyone else (or indeed yourself at some point in
> the future) who isn't familiar with the many, many idiosyncrasies of
> shell languages.

There's no chance you could confuse anyone with this functionality, as it is
mandated by POSIX.


-- 
With best regards,
Andrey Repin
Thursday, April 21, 2016 19:33:42

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-04-21 16:35 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-19 21:00 git and absolute Windows-style paths silverwind
2016-04-19 21:58 ` Marco Atzeri
2016-04-19 22:28   ` Ken Brown
2016-04-20 10:28     ` Adam Dinwoodie
2016-04-20  0:49 ` Bill Smith
2016-04-20 15:52   ` silverwind
2016-04-20 16:06     ` Eliot Moss
2016-04-20 16:15       ` Brian Clifton
2016-04-20 18:18         ` Ernie Rael
2016-04-20 20:39         ` Eliot Moss
2016-04-20 21:17           ` Adam Dinwoodie
2016-04-21 19:50             ` Andrey Repin
2016-04-20 23:40           ` Ernie Rael
2016-04-21  0:14             ` Eliot Moss
2016-04-21 15:19               ` Ray Donnelly
2016-04-21 16:01                 ` Ray Donnelly
2016-04-20 16:46       ` silverwind
2016-04-20 16:56         ` Adam Dinwoodie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).