Skip to content

Commit 9952fa6

Browse files
derrickstoleeGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #3791: Various fixes around safe.directory
The first three commits are rebased versions of those in gitgitgadget#1215. These allow the following: 1. Fix `git config --global foo.bar <path>` from allowing the `<path>`. As a bonus, users with a config value starting with `/` will not get a warning about "old-style" paths needing a "`%(prefix)/`". 2. When in WSL, the path starts with `/` so it needs to be interpolated properly. Update the warning to include `%(prefix)/` to get the right value for WSL users. (This is specifically for using Git for Windows from Git Bash, but in a WSL directory.) 3. When using WSL, the ownership check fails and reports an error message. This is noisy, and happens even if the user has marked the path with `safe.directory`. Remove that error message.
2 parents b051576 + c99fcf1 commit 9952fa6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

compat/mingw.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3121,9 +3121,7 @@ int is_path_owned_by_current_sid(const char *path, struct strbuf *report)
31213121
DACL_SECURITY_INFORMATION,
31223122
&sid, NULL, NULL, NULL, &descriptor);
31233123

3124-
if (err != ERROR_SUCCESS)
3125-
error(_("failed to get owner for '%s' (%ld)"), path, err);
3126-
else if (sid && IsValidSid(sid)) {
3124+
if (err == ERROR_SUCCESS && sid && IsValidSid(sid)) {
31273125
/* Now, verify that the SID matches the current user's */
31283126
static PSID current_user_sid;
31293127
BOOL is_member;

setup.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -1781,10 +1781,19 @@ const char *setup_git_directory_gently(int *nongit_ok)
17811781
break;
17821782
case GIT_DIR_INVALID_OWNERSHIP:
17831783
if (!nongit_ok) {
1784+
struct strbuf prequoted = STRBUF_INIT;
17841785
struct strbuf quoted = STRBUF_INIT;
17851786

17861787
strbuf_complete(&report, '\n');
1787-
sq_quote_buf_pretty(&quoted, dir.buf);
1788+
1789+
#ifdef __MINGW32__
1790+
if (dir.buf[0] == '/')
1791+
strbuf_addstr(&prequoted, "%(prefix)/");
1792+
#endif
1793+
1794+
strbuf_add(&prequoted, dir.buf, dir.len);
1795+
sq_quote_buf_pretty(&quoted, prequoted.buf);
1796+
17881797
die(_("detected dubious ownership in repository at '%s'\n"
17891798
"%s"
17901799
"To add an exception for this directory, call:\n"

0 commit comments

Comments
 (0)