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. */
| 523 | * submodules). Deliberately a filesystem check, not a git invocation — the whole |
| 524 | * point is to learn something `rev-parse` cannot tell us, because it walks up. */ |
| 525 | static bool git_has_own_dot_git(const char *root_path) { |
| 526 | char path[CBM_SZ_4K]; |
| 527 | int written = snprintf(path, sizeof(path), "%s/.git", root_path); |
| 528 | if (written <= 0 || (size_t)written >= sizeof(path)) { |
| 529 | return false; |
| 530 | } |
| 531 | struct stat st; |
| 532 | return stat(path, &st) == 0 && (S_ISDIR(st.st_mode) || S_ISREG(st.st_mode)); |
| 533 | } |
| 534 | |
| 535 | /* Does the ancestor repository actually track anything inside this directory? |
| 536 | * Emptiness distinguishes "a scratch folder that merely sits under a repo" from |