| 290 | } |
| 291 | |
| 292 | static bool watcher_resolve_git_executable(char output[CBM_SZ_4K]) { |
| 293 | output[0] = '\0'; |
| 294 | DWORD required = GetEnvironmentVariableW(L"PATH", NULL, 0U); |
| 295 | wchar_t *path = required > 0U ? malloc((size_t)required * sizeof(*path)) : NULL; |
| 296 | DWORD length = path ? GetEnvironmentVariableW(L"PATH", path, required) : 0U; |
| 297 | if (!path || length == 0U || length >= required) { |
| 298 | free(path); |
| 299 | return false; |
| 300 | } |
| 301 | const wchar_t *entry = path; |
| 302 | for (const wchar_t *cursor = path;; cursor++) { |
| 303 | if (*cursor != L';' && *cursor != L'\0') { |
| 304 | continue; |
| 305 | } |
| 306 | if (watcher_windows_git_candidate(entry, (size_t)(cursor - entry), output)) { |
| 307 | free(path); |
| 308 | return true; |
| 309 | } |
| 310 | if (*cursor == L'\0') { |
| 311 | break; |
| 312 | } |
| 313 | entry = cursor + 1; |
| 314 | } |
| 315 | free(path); |
| 316 | return false; |
| 317 | } |
| 318 | #endif |
| 319 | |
| 320 | /* Run one literal argv vector in a contained process tree. active_git is |
no test coverage detected