Repository navigation
fix st_ino on Windows so includeIf works on subst drives - #6586
ChrisIdema wants to merge 1 commit into
Conversation
Signed-off-by: Chris Idema <github_chris_idema@proton.me>
b6ffab1 to
f3dafa9
Compare
dscho
left a comment
There was a problem hiding this comment.
Thank you for working on this @ChrisIdema. In general, this is of course a good idea.
Please note that the ramifications from your change are far, far, far away from affecting only includeIf. You're changing the implementation of lstat(), Which is most prominently used to quickly verify that files in a work tree are up to date. Which they now will not be, Not when the Git index was written by a previous version and the user updated to a Git version including your change. Refreshing and rehashing is very expensive. Therefore, I think this must be an intentional upgrade by the user. You can't just force everybody, especially those with monorepos, to involunatrily refresh their potentially huge Git indices.
So I think that this needs, definitely needs, to be an opt-in.
Furthermore, we really need to deal with the fact that Git assumes that inode numbers are unsigned ints, that is, 32-bit. Your patch truncates a 64-bit number. So what was assumed to be unique no longer is.
Besides, if I saw correctly, you only covered the regular mingw_lstat(), but not the fscache_lstat(). That will require an equivalent change.
Finally, note that this is missing documentation. Which in this case is not a formality because there are plenty of file systems that do not provide those pseudo-inode numbers. Granted, NTFS and ReFS support it, but FAT doesn't. Most network file systems also do not, if I recall correctly.
| struct mingw_stat { | ||
| _dev_t st_dev; | ||
| _ino_t st_ino; | ||
| uint64_t st_ino; |
There was a problem hiding this comment.
That is unfortunately incompatible with the unsigned int sd_ino declaration, to which the st_ino values are assigned.
| buf->st_ino = 0; | ||
| buf->st_ino = ((uint64_t)fdata.nFileIndexHigh << 32) | | ||
| ((uint64_t)fdata.nFileIndexLow << 0); |
There was a problem hiding this comment.
Since the Git index stores that statinfo to indicate whether an index entry is up to date, rolling out this change to everybody without making it opt-in will actually render every single Git index out of date in every Git worktree on Windows on this entire planet.
Even worse, should multiple Git implementations be used on the same work tree, they would now flip-flop. For example, if you use regular Git for Windows with this change and a libgit2 based one or an older menu Git, for example via Visual Studio, you will now constantly rehash and refresh the index. That's quite costly.
So in the least, I would suggest to make this a config option. Defaulting to off, of course, to avoid everybody and their parents to waste electricity and time.
|
Thanks for the quick reply. In the topic on the issue there has been radio silence for 3 weeks so I thought I take the initiative to create a pull request.
On windows So by defining
Currently nothing is assumed unique as st_ino is always 0...
If the I think the only solution is to modify or override |
You mean 32-bit, right? I do think though that there are hash algorithms that are acceptable here (probably even already in libgit.a). And as you point out, collisions are kind of expected, if the inode number is allowed to be zero for all files.
They are. The So... opt-in? |
rimrul
left a comment
There was a problem hiding this comment.
We'll probably want tests for this and a less terse commit message.
| buf->st_size = fdata.nFileSizeLow | | ||
| (((off_t)fdata.nFileSizeHigh)<<32); | ||
| buf->st_dev = buf->st_rdev = 0; /* not used by Git */ | ||
| buf->st_dev = buf->st_rdev = fdata.dwVolumeSerialNumber; |
There was a problem hiding this comment.
st_rdev probably should stay 0 and keep the comment that it's not used.
There was a problem hiding this comment.
But it's literally used by git. The comment is wrong.
It meant
I think you made a good case to not touch I can think of several ways to do it. But it's hard for me to find the git way to do it. |
Hehe, that was actually not the case I wanted to make. To the contrary, I think that if you want to fix this problem, you have to touch And of course introduce a config option to zero that sd_ino/sd_rdev on Windows by default to retain backwards-compatibility as well as compatibility with libgit2, JGit, older MinGit, etc. |
What do you mean exactly by "by default". Do you mean as a build flag so that users have to enable to use it? Is this so that people can test it? I'm asking, because if there is an acceptable solution wouldn't you want it enabled for everyone eventually? I'd like to know what the "git way" is of approaching this. |
No, by "config option" I was referring to a setting that can be enabled/disabled via Also, I don't think I impressed enough how much of a cost upgrading from inode numbers being forced to zero to non-zero inode numbers would be. Do note, as I have pointed out above, that those inode numbers are persisted in the Git index. When you run Imagine that you are a user of a big monorepo that has millions and millions of files. Your Git index has stat data for all of them, and all of them have an rdev and an inode set to zero. Now some wonderful contributor implements a very neat change so that inode numbers are now properly set. The next thing you do is run Phew, that costs some time, right? But now you look at the same thing with Visual Studio because that's what you usually work in. Or with GitHub Desktop, or any other third party program that uses their own Git implementation. Naturally, they ship with an older version of MinGit (or are based on libgit2 or JGit or gitoxide or whatever, else, really) that does not support the feature where proper, correct inode numbers are calculated. So when those programs try to see which files are up to date... They see that all of them are modified. All of them have differing inode numbers because that Git expected the inode numbers to be zero, but they're recorded as non-zero in the Git index. So now the older Git needs to rehash every single file in order to update the index. Phew, that costs some time again, right? Let's check with the new Git for Windows' Phew, that again costs a lot of time, right? By now you're actually no longer that certain that this was such a wonderful contribution. You wished that somebody had told you that you can opt into it or you can opt out of it and at least told you what to expect. But nobody did. Except that I want this to be an opt in so that by default, those costs are not paid by Git for Windows users, especially those with large repositories. And I want that config option to be prominently featured in the release notes. And eventually, when enough time has passed so that other Git implementations and applications shipping with MinGit had a chance to catch up, then we flip the default. Makes sense now? |
No description provided.