{"thread":{"id":"66482","subject":"FW: [Windows] safe.directory: unreachable UNC entry stalls every command in a repo that fails the ownership check (~25 s)","startedAt":"2026-10-07T13:21:11Z","lastAt":"2026-10-07T13:21:11Z","messageCount":1,"participants":["Daniel Gullberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"554370","messageId":"PH0PR03MB594476FBBE28305EA52BB482FD942@PH0PR03MB5944.namprd03.prod.outlook.com","threadId":"66482","inReplyTo":"PH0PR03MB59443B1A6BA969CD509B8C22FD942@PH0PR03MB5944.namprd03.prod.outlook.com","subject":"FW: [Windows] safe.directory: unreachable UNC entry stalls every command in a repo that fails the ownership check (~25 s)","fromName":"Daniel Gullberg","fromEmail":"daniel.gullberg@mmm.com","sentAt":"2026-10-07T13:21:11Z","receivedAt":"2026-10-07T13:21:11Z","isPatch":false,"sender":{"key":"daniel.gullberg@mmm.com","avatar":null},"body":"What did you do before the bug happened?\n\nOn Windows, a repository on an SMB share mapped to a drive letter\n(P: = file://192.168.56.101/TestDir, Samba on a VM; files are owned by a\ndifferent SID than the current user) is used with a global config\nthat lists several safe.directory entries. One entry points to a UNC\npath on a host that is currently not reachable:\n\n  git config --global --add safe.directory \\\n      '//192.168.1.190/dummy-test/repo.git'\n\n  cd P:\\\n  git status\n\nWhat did you expect to happen?\n\nAn entry that cannot match the repository being opened should not\nslow down the command. \"git status\" should take about 2 s, as it\ndoes without the entry.\n\nWhat happened instead?\n\nThe first \"git status\" takes about 29 s. Repeated runs shortly\nafterwards take about 1.8 s (Windows seems to cache the failed host\nlookup for a while). Removing the single unreachable entry from the\nglobal config brings the first run down to about 2.3 s.\n\nTimings (same repo, same session):\n  with unreachable safe.directory entry:  29.07 s, 1.93 s, 1.78 s\n  entry removed:                           2.27 s, 1.58 s\n\nGIT_TRACE2_PERF shows the time is spent before the worktree is set\nup, with no git work in between:\n\n  13:43:00.798  main  ancestry: git.exe, powershell.exe, ...\n  13:43:21.973  main  worktree://192.168.56.101/TestDir\n  (exit after 26.2 s total, of which about 5 s are git work)\n\nA plain filesystem probe of the dead host root from PowerShell\n(Test-Path '//192.168.1.190/dummy/') also takes about 25 s to fail,\nso the wait appears to be the Windows network connect timeout.\n\nMy hypothesis, not verified in the source: the configured\nsafe.directory values are normalized (resolved to a real path) when\nchecked, which makes Windows contact the unreachable host. The\nownership check is only done when the repository is not owned by\nthe current user, which is always the case on this share. Comparing\nthe entry against the repository path first, and only resolving\nentries that could match, would avoid contacting unrelated hosts.\n\nImpact: tools that run git often, such as TortoiseGit, pay the delay\nrepeatedly (our Commit dialog took ~30 s to update). Stale entries\nfor old or offline network locations are common, so this is easy to\nhit.\n\nWhat's different between what you expected and what happened?\n\nAn unrelated, unreachable safe.directory entry makes git commands\nwait about 25 s.\n\nAnything else you want to add:\n\nReproduced with Git for Windows 2.56.0.windows.2 and 2.46.1.windows.1.\nRelated reports (not the same problem):\n  https://github.com/git-for-windows/git/issues/5673\n  https://github.com/git-for-windows/git/issues/6359\n\n[System Info]\ngit version:\ngit version 2.56.0.windows.2\ncpu: x86_64\nbuilt from commit: cc4dbf752a05efdc0e04e71fd3e8110d11bdd35c\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nrust: disabled\nfeature: fsmonitor--daemon\ngettext: enabled\nlibcurl: 8.22.0\nOpenSSL: OpenSSL 3.5.9 29 Sep 2026\nzlib: 1.3.2\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Windows 10.0 26200\ncompiler info: gnuc: 16.2\nlibc info: no libc information available\n$SHELL (typically, interactive shell): C:\\Programs\\Git\\usr\\bin\\bash.exe\n\n\n\n\nBest regards\n\nDaniel Gullberg\n3M Personal Safety Division | Welding Center of Excellence\n3M Svenska AB, Ernst Hedlunds v.35 | 785 30 Gagnef | Sweden\nTime: GMT +1:00\nmailto:daniel.gullberg@mmm.com\n\n\n\n\n\n\n"}]}