1#![deny(missing_docs)]
29#![forbid(unsafe_code)]
30
31pub const DOT_GIT_DIR: &str = ".git";
33
34pub const MODULES: &str = "modules";
36
37pub mod repository;
39
40pub mod is_git {
42 use std::path::PathBuf;
43
44 #[derive(Debug, thiserror::Error)]
46 #[expect(missing_docs)]
47 pub enum Error {
48 #[error("Could not find a valid HEAD reference")]
49 FindHeadRef(#[from] gix_ref::file::find::existing::Error),
50 #[error("Missing HEAD at '.git/HEAD'")]
51 MissingHead,
52 #[error("Expected HEAD at '.git/HEAD', got '.git/{}'", .name)]
53 MisplacedHead { name: bstr::BString },
54 #[error("Expected an objects directory at '{}'", .missing.display())]
55 MissingObjectsDirectory { missing: PathBuf },
56 #[error("The worktree's private repo's commondir file at '{}' or it could not be read", .missing.display())]
57 MissingCommonDir { missing: PathBuf, source: std::io::Error },
58 #[error("Expected a refs directory at '{}'", .missing.display())]
59 MissingRefsDirectory { missing: PathBuf },
60 #[error(transparent)]
61 GitFile(#[from] crate::path::from_gitdir_file::Error),
62 #[error("Could not retrieve metadata of \"{path}\"")]
63 Metadata { source: std::io::Error, path: PathBuf },
64 #[error(
65 "The repository's config file doesn't exist or didn't have a 'bare' configuration or contained core.worktree without value"
66 )]
67 Inconclusive,
68 #[error("Could not obtain current directory for resolving the '.' repository path")]
69 CurrentDir(#[from] std::io::Error),
70 }
71}
72
73mod is;
74#[expect(
75 deprecated,
76 reason = "this re-export preserves compatibility with the deprecated API"
77)]
78pub use is::submodule_git_dir as is_submodule_git_dir;
79pub use is::{bare as is_bare, git as is_git};
80
81pub mod upwards;
83pub use upwards::function::{discover as upwards, discover_opts as upwards_opts};
84
85pub mod path;
87
88pub mod parse;