Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect path conversion (trailing slash) #17

Merged
merged 1 commit into from
Jun 1, 2018

Conversation

dscho
Copy link
Member

@dscho dscho commented May 30, 2018

This is intended to be squashed into 50159fe.

The problem with the original approach is not that it is completely
bogus. After all, when you pass the option --prefix=/tmp/ to Git, you do
want to end up with a trailing slash.

The real problem with the original approach is that it simply changed
path_conv, completely obvlivious and careless about other users of
path_conv.

That was really wrong, of course, and cost us time, sweat and tears. The
appropriate approach is to not affect other users, but instead
introduce a flag that we use in our caller, so that everybody gets
what they want:

  • emulation of inodes on FAT by calculating the hash on the normalized
    path: works.

  • MSYS2's conversion of "POSIX" paths to Windows paths: works.

@dscho dscho force-pushed the trailing-slash branch from e82b179 to a31f5e3 Compare May 30, 2018 06:04
The problem with the original approach is not that it is completely
bogus. After all, when you pass the option --prefix=/tmp/ to Git, you do
want to end up with a trailing slash.

The real problem with the original approach is that it simply changed
path_conv, completely oblivious and careless about other users of
path_conv.

That was really wrong, of course, and cost us time, sweat and tears. The
appropriate approach is to *not* affect other users, but instead
introduce a flag that we use in *our* caller, so that everybody gets
what they want:

- emulation of inodes on FAT by calculating the hash on the normalized
  path: works.

- MSYS2's conversion of "POSIX" paths to Windows paths: works.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the trailing-slash branch from a31f5e3 to e0f49d0 Compare May 30, 2018 06:09
@dscho
Copy link
Member Author

dscho commented May 30, 2018

@mingwandroid could you have a look, please?

@mingwandroid
Copy link

IMHO I should've gone further and fixed the callers. Your fix for FAT should take place at the inode calculation site.

I believe your 'not completely bogus' statement (thanks! almost a complement) shows that you are coming round to seeing this with a bit more clarity than before.

A function should do the most obvious things by default when such a thing exists and this is a clear case of that. Adding a flag is ugly.

So while I'll say LGTM I mean "ok it's better than the bug and I'm not going to have time to fix this issue as I think it should be fixed, at the site of the old assumption we want to break in the interests of code simplicity and sanity"

that was really wrong, of course

Disagree entirely.

@Alexpux I'd go ahead and merge this anyway.

@dscho
Copy link
Member Author

dscho commented May 31, 2018

Your fix for FAT should take place at the inode calculation site.

@mingwandroid That assumes that it is the responsibility of the MSYS2 fork to take care of the inode calculation. But that is not the case. It is Cygwin's decision to define the behavior of the normalization. It's not even your decision, much as you pretend it to be.

I believe your 'not completely bogus' statement (thanks! almost a complement) shows that you are coming round to seeing this with a bit more clarity than before

You mean a "compliment", right?

And I would not call it that. I am not "coming around" to see how your approach is correct. It still is not.

I am coming around to understand the problem you tried to solve. The problem, as I see it, is that when you pass a parameter to a non-MSYS2 program that looks like it is a path prefix (/usr/), then the program probably wants the trailing slash.

And this problem is simply introduced by MSYS2: it reuses Cygwin's path_conv to perform something slightly related, yet still different. We are not trying to normalize anything, we are trying to convert a command-line parameter (or part thereof, or an environment variable, or part thereof) from Unix path style to Win32 path style.

And your workaround for the bug simply breaks too much to be a real fix. It breaks basic assumptions by Cygwin's code, and is therefore no good.

A function should do the most obvious things by default when such a thing exists and this is a clear case of that. Adding a flag is ugly.

When you design an architecture, you are at liberty to define what a function should do, and to use your understanding of what is obvious and what is not to inform on that design.

This design is neither yours, nor yours to change.

Adding a flag is the least intrusive way to achieve what you want to achieve, when the original API was not designed to give you what you want.

that was really wrong, of course

Disagree entirely.

Well, you broke the Cygwin runtime. That is totally wrong. You can't just simply change a central part of a piece of software to do things very differently than before, without adjusting all the callers to expect the new behavior. And you did not adjust even a single caller.

The better way to change this is to not break anything else.

@Alexpux I'd go ahead and merge this anyway.

You misunderstand. I disagree with @Alexpux on too many things, including his terse (to the point of being unhelpful) communication, therefore I had to abandon my plans to integrate Git for Windows' changes into MSYS2.

Therefore, Git for Windows maintains its own fork of the Cygwin runtime that is based on the MSYS2 runtime's patches, but diverges, and will probably diverge worse, still.

I did not give up hope yet to collaborate with the Cygwin project on integrating at least a large part of the modifications (probably hidden behind options e.g. in /etc/nsswitch.conf), yet. I just have to find the time. My working style is pretty compatible with the Cygwin maintainers', which makes me hopeful.

@dscho
Copy link
Member Author

dscho commented May 31, 2018

@mingwandroid maybe we can turn this thread around to a much more productive direction, though.

It is my fault, for not specifying precisely what I would like from you. Sorry about that.

I would like you to have a look whether this workaround would match what you recall from the original problem (you seemed to vaguely remember something from GCC's build scripts, but I fail to see how that relates to this here problem, as nothing in GCC's build scripts shouts "MINGW" to me, therefore msys2_path_conv.cc should not even play a role here).

So: can you please try to remember the details of the bug, and then apply this to a review whether this patch is correct? I really do not need any style or design review, I really only need you to confirm that it does what it is supposed to, or in the alternative to point out to me where it goes wrong.

Thank you.

@mingwandroid
Copy link

Yes I can. I was making native Windows cases Linux targeting cross compilers and glibc likes job backwards seps.

This design is neither yours, nor yours to change.

MSYS2s runtime is a fork of cygwin specifically so we can make such changes. You are right I should've fixed all the callsites though but I'm not interested in any moral rights style argument about design in relation to this at all.

I've already said this could be merged though but I have less and less time for MSYS2 these days for which I'm truly sorry so I cannot do a good review of it.

@dscho
Copy link
Member Author

dscho commented Jun 1, 2018

I was making native Windows cases Linux targeting cross compilers and glibc likes job backwards seps.

I am truly sorry: my English parsing elude me. I do not understand what that sentence means. If anybody can help me, that would be awesome.

Be that as it may, I'll just merge this so that we can have the fix soon.

@dscho dscho merged commit 5b0abb2 into git-for-windows:master Jun 1, 2018
@dscho dscho deleted the trailing-slash branch June 1, 2018 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants