True when root_path carries its OWN repository marker: a `.git` directory, or * a `.git` file (the gitlink form used by linked worktrees and initialized * submodules). Deliberately a filesystem check, not a git invocation — the whole * point is to learn something `rev-parse` cannot tell us, because it walks up. */
| 462 | * submodules). Deliberately a filesystem check, not a git invocation — the whole |
| 463 | * point is to learn something `rev-parse` cannot tell us, because it walks up. */ |
| 464 | static bool git_has_own_dot_git(const char *root_path) { |
| 465 | char path[CBM_SZ_4K]; |
| 466 | int written = snprintf(path, sizeof(path), "%s/.git", root_path); |
| 467 | if (written <= 0 || (size_t)written >= sizeof(path)) { |
| 468 | return false; |
| 469 | } |
| 470 | struct stat st; |
| 471 | return stat(path, &st) == 0 && (S_ISDIR(st.st_mode) || S_ISREG(st.st_mode)); |
| 472 | } |
| 473 | |
| 474 | /* Does the ancestor repository actually track anything inside this directory? |
| 475 | * Emptiness distinguishes "a scratch folder that merely sits under a repo" from |