8000 util/win32: Continue if access is denied when deleting a folder. by lrm29 · Pull Request #6929 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@lrm29
Copy link
Contributor
@lrm29 lrm29 commented Oct 25, 2024

I'm afraid people do put Git repos on OneDrive... It seems to like to prevent folders from being deleted, causing libgit2 operations to handle ERROR_ACCESS_DENIED, and preventing us from switching branches/merging etc.

I think this change brings libgit2 in line with the behaviour of Git for Windows. The rmdir function is located here. The function is_file_in_use_error not only checks for ERROR_SHARING_VIOLATION, but also ERROR_ACCESS_DENIED:

static inline int is_file_in_use_error(DWORD errcode)
{
	switch (errcode) {
	case ERROR_SHARING_VIOLATION:
	case ERROR_ACCESS_DENIED:
		return 1;
	}

	return 0;
}

Completely understand any hesitation about merging this, but thought it might be useful to at least raise it so others can search for it. I've tried it out and it seems to work ok.

Of course, it means empty folders can end up lying around in your local Git repository which is also confusing. But Git for Windows is the same.

@ethomson
Copy link
Member

Seems reasonable!

@ethomson ethomson merged commit c6111ec into libgit2:main Oct 29, 2024
19 checks passed
@ethomson ethomson added the bug label Dec 16, 2024
@lrm29 lrm29 deleted the util_win32_rmdir_access_denied branch January 7, 2025 61FC 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0