git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4] mingw: check that the file attributes are valid before modifying them

From
AGAreaZR via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 18, 2024, 00:37 UTC
Message-ID
<pull.1413.v4.git.git.1734482229018.gitgitgadget@gmail.com>
In-Reply-To
<pull.1413.v3.git.git.1673189354738.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>

If the attributes are invalid, return -1 to indicate an error.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    mingw: check that the file attributes are valid before modifying them
    
    Thanks for taking the time to contribute to Git! Please be advised that
    the Git community does not use github.com for their contributions.
    Instead, we use a mailing list (git@vger.kernel.org) for code
    submissions, code reviews, and bug reports. Nevertheless, you can use
    GitGitGadget (https://gitgitgadget.github.io/) to conveniently send your
    Pull Requests commits to our mailing list.
    
    Please read the "guidelines for contributing" linked above!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1413%2FAreaZR%2Fset-hidden-flag-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1413/AreaZR/set-hidden-flag-v4
Pull-Request: https://github.com/git/git/pull/1413
Range-diff vs v3:
 1:  0cbe8bce617 = 1:  0fed7ade880 mingw: check that the file attributes are valid before modifying them
 compat/mingw.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/compat/mingw.c b/compat/mingw.c
index 63f36c893bf..7f52a4362fe 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -446,6 +446,11 @@ static inline int needs_hiding(const char *path)
 static int set_hidden_flag(const wchar_t *path, int set)
 {
 	DWORD original = GetFileAttributesW(path), modified;
+	if (original == INVALID_FILE_ATTRIBUTES) {
+		errno = err_win_to_posix(GetLastError());
+		return -1;
+	}
+
 	if (set)
 		modified = original | FILE_ATTRIBUTE_HIDDEN;
 	else

base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
-- 
gitgitgadget
Previous: Rose via GitGitGadget
Message 4 of 4 in “mingw: check that the file attributes are valid”
  1. mingw: check that the file attributes are validRose via GitGitGadget, Dec 22, 2022
  2. mingw: check that the file attributes are validRose via GitGitGadget, Jan 8, 2023
  3. mingw: check that the file attributes are valid before modifying themRose via GitGitGadget, Jan 8, 2023
  4. mingw: check that the file attributes are valid before modifying themAreaZR via GitGitGadget, Dec 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.