Whether `dir` is an actual Git directory: a readable `HEAD` plus the `objects` and `refs` stores (the same minimal shape Git's own `is_git_directory` check requires). A directory holding only `HEAD` — the forged-marker shape the review pinned — is rejected. A linked-worktree gitdir (which delegates `objects`/`refs` to its `commondir`) passes when the common store validates and the worktree gitdir
(dir: &Path)
| 936 | /// gitdir (which delegates `objects`/`refs` to its `commondir`) passes when |
| 937 | /// the common store validates and the worktree gitdir holds its own `HEAD`. |
| 938 | fn is_actual_git_directory(dir: &Path) -> bool { |
| 939 | if !dir.join("HEAD").is_file() { |
| 940 | return false; |
| 941 | } |
| 942 | if dir.join("objects").is_dir() && dir.join("refs").is_dir() { |
| 943 | return true; |
| 944 | } |
| 945 | // Linked worktree gitdir: `common dir` names the shared Git directory, |
| 946 | // resolved relative to the worktree gitdir itself. |
| 947 | if let Ok(common) = std::fs::read_to_string(dir.join("commondir")) { |
| 948 | let common = common.trim(); |
| 949 | if !common.is_empty() { |
| 950 | let common_path = std::path::Path::new(common); |
| 951 | let resolved = if common_path.is_absolute() { |
| 952 | common_path.to_path_buf() |
| 953 | } else { |
| 954 | dir.join(common_path) |
| 955 | }; |
| 956 | if resolved.join("objects").is_dir() && resolved.join("refs").is_dir() { |
| 957 | return true; |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | false |
| 962 | } |
| 963 | |
| 964 | /// Hash the contents of a file using Blake3. |
| 965 | /// |
no test coverage detected