Skip to content

Commit 4e914f8

Browse files
committed
Remove handling of environment variables (#301)
We should find another way that plays well with configuration. Probably it needs another version of this function with more parameters.
1 parent 54be8e3 commit 4e914f8

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

git-discover/src/is.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
use std::{
2-
ffi::OsStr,
3-
path::{Path, PathBuf},
4-
};
1+
use std::{ffi::OsStr, path::Path};
52

63
/// Returns true if the given `git_dir` seems to be a bare repository.
74
///
8-
/// Please note that repositories without any file in their work tree will also appear bare.
5+
/// Please note that repositories without an index generally _look_ bare, even though they might also be uninitialized.
96
pub fn bare(git_dir_candidate: impl AsRef<Path>) -> bool {
107
let git_dir = git_dir_candidate.as_ref();
118
!(git_dir.join("index").exists() || (git_dir.file_name() == Some(OsStr::new(".git")) && git_dir.is_file()))
129
}
1310

14-
/// What constitutes a valid git repository, and what's yet to be implemented, returning the guessed repository kind
11+
/// What constitutes a valid git repository, returning the guessed repository kind
1512
/// purely based on the presence of files. Note that the git-config ultimately decides what's bare.
1613
///
1714
/// * [ ] git files
1815
/// * [x] a valid head
1916
/// * [ ] git common directory
20-
/// * [ ] respect GIT_COMMON_DIR
2117
/// * [x] an objects directory
22-
/// * [x] respect GIT_OBJECT_DIRECTORY
2318
/// * [x] a refs directory
19+
// TODO: allow configuring common dirs at least
2420
pub fn git(git_dir: impl AsRef<Path>) -> Result<crate::repository::Kind, crate::is_git::Error> {
2521
let dot_git = git_dir.as_ref();
2622

@@ -43,9 +39,7 @@ pub fn git(git_dir: impl AsRef<Path>) -> Result<crate::repository::Kind, crate::
4339
}
4440

4541
{
46-
let objects_path = std::env::var("GIT_OBJECT_DIRECTORY")
47-
.map(PathBuf::from)
48-
.unwrap_or_else(|_| dot_git.join("objects"));
42+
let objects_path = dot_git.join("objects");
4943
if !objects_path.is_dir() {
5044
return Err(crate::is_git::Error::MissingObjectsDirectory { missing: objects_path });
5145
}

0 commit comments

Comments
 (0)