-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Misleading warning when a directory is named .gitignore #5068
Comments
[`CreateFileW()` requires `FILE_FLAG_BACKUP_SEMANTICS` to create a directory handle](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew#directories) and errors out with `ERROR_ACCESS_DENIED` without this flag. Fall back to accessing Directory handles this way. This fixes #5068
Thank you @rimrul for fixing this! |
Git for Windows used [to issue a misleading warning when `.gitignore` was a directory](git-for-windows/git#5068), which has been [fixed](git-for-windows/git#5342). Signed-off-by: gitforwindowshelper[bot] <[email protected]>
Thanks! |
Please test the latest snapshot. |
I have just tested For comparison since this was on a different Windows 11 system, and since I had not used PortableGit before to test this, I also tested |
This is conceptually related to #1301, but not configuration-dependent.
Setup
64-bit.
I have confirmed this issue on multiple machines running different versions and architectures of Windows. The technical details given here are for a Windows 11 ARM64 system running the 64-bit x86-64 build of Git for Windows (the system automatically takes care of the necessary emulation). But this issue is not specific in any way to ARM64 systems, and this is with an official stable x86-64 build, not an ARM64 build. The output of
ver
shows the major version number as "10" but this is a Windows 11 system.The reason I have given the details of that installation, rather than my x86-64 Windows 10 installation, is that Git for Windows is installed via
scoop
in that other installation. I am unsure if reports from such an installation are considered as useful, since the template seems to indicate that ainstall-options.txt
file whose contents can be shown by one of the exact commands in the template is required. I would be pleased to provide more information or set up additional environments if needed.defaults?
In the installation whose details are shown, I used the x86-64 installer, running as a limited user, to install in the limited user's local
Programs
directory, without addinggit
to thePATH
environment variable. But I have confirmed that this issue does not depend on running as a limited user, installing in that way, or refraining from modifying thePATH
.to the issue you're seeing?
As far as I can tell, this happens with Git for Windows in all environments. It does not happen when running Git on operating systems other than Windows.
Details
Technical details presented here are from running Git from Bash in the provided Git Bash shell, but I have confirmed that this is not specific to that.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
I expect no errors or warnings to be reported, even though having a directory named
.gitignore
is unusual and should probably be avoided. The reason I expect this is that it works outside of Windows.Secondarily, if all operations have completed successfully with their full intended resulting state, then I expect that no messages are issued that would tend to cause an experienced user of Git for Windows to believe that some operation failed or was only partially successful.
Although staging succeeds, the
git add .
andgit status
commands output:But both commands actually succeeded fully, including at staging
.gitignore/a
and showing.gitignore/a
as staged:I do not insist that this warning is technically wrong. My guess is that an attempt is made to open it as a regular file, which fails because it is a directory and reports that failure accurately, and then there is no undesirable effect from this besides the warning, since a directory named
.gitignore
is not treated specially. But this appears to be indicating that not all files were staged or that the resulting state differs from what the user may have intended, which is not the case. Furthermore, on non-Windows systems, these commands have the same successful effect, while not indicating any errors or warnings.URL to that repository to help us with testing?
This happens whenever a directory named
.gitignore
is present, and is not specific to a particular repository. I expect that this condition is typically accidental. I was motivated to check how Git for Windows behaved in this situation by gitbutlerapp/gitbutler#3876 and GitoxideLabs/gitoxide#1386.The text was updated successfully, but these errors were encountered: