1#![deny(missing_docs, rust_2018_idioms)]
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 #[allow(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("The repository's config file doesn't exist or didn't have a 'bare' configuration or contained core.worktree without value")]
65 Inconclusive,
66 #[error("Could not obtain current directory for resolving the '.' repository path")]
67 CurrentDir(#[from] std::io::Error),
68 }
69}
70
71mod is;
72#[allow(deprecated)]
73pub use is::submodule_git_dir as is_submodule_git_dir;
74pub use is::{bare as is_bare, git as is_git};
75
76pub mod upwards;
78pub use upwards::function::{discover as upwards, discover_opts as upwards_opts};
79
80pub mod path;
82
83pub mod parse;