Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4420ae9

Browse files
committed
adjustments due to breaking changes in git_path (#331)
1 parent dfa1e05 commit 4420ae9

7 files changed

Lines changed: 12 additions & 11 deletions

File tree

git-config/src/file/resolve_includes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ fn gitdir_matches(
198198
return Ok(true);
199199
}
200200

201-
let expanded_git_dir = git_path::realpath(git_path::from_byte_slice(&git_dir), std::env::current_dir().unwrap())?;
202-
let expanded_git_dir = git_path::into_bstr(expanded_git_dir);
201+
let expanded_git_dir = git_path::into_bstr(git_path::realpath(git_path::from_byte_slice(&git_dir))?);
203202
Ok(git_glob::wildmatch(
204203
pattern_path.as_bstr(),
205204
expanded_git_dir.as_bstr(),

git-config/tests/file/from_paths/includes/conditional/gitdir/util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ impl Condition {
6060
impl GitEnv {
6161
pub fn repo_name(repo_name: impl AsRef<Path>) -> crate::Result<Self> {
6262
let tempdir = tempfile::tempdir()?;
63-
let cwd = std::env::current_dir()?;
64-
let root_dir = git_path::realpath(tempdir.path(), &cwd)?;
63+
let root_dir = git_path::realpath(tempdir.path())?;
6564
let worktree_dir = root_dir.join(repo_name);
6665
std::fs::create_dir_all(&worktree_dir)?;
67-
let home_dir = git_path::realpath(tempdir.path(), cwd)?;
66+
let home_dir = git_path::realpath(tempdir.path())?;
6867
Ok(Self {
6968
tempdir,
7069
root_dir,

git-discover/src/upwards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn parse_ceiling_dirs(ceiling_dirs: &[u8]) -> Vec<PathBuf> {
102102
}
103103

104104
if should_normalize {
105-
if let Ok(normalized) = git_path::realpath(&dir, "") {
105+
if let Ok(normalized) = git_path::realpath(&dir) {
106106
dir = Cow::Owned(normalized);
107107
}
108108
}

git-discover/tests/upwards/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn from_existing_worktree() -> crate::Result {
162162
assert_eq!(trust, expected_trust());
163163
let (git_dir, worktree) = path.into_repository_and_work_tree_directories();
164164
assert_eq!(
165-
git_dir.strip_prefix(git_path::realpath(&top_level_repo, std::env::current_dir()?).unwrap()),
165+
git_dir.strip_prefix(git_path::realpath(&top_level_repo).unwrap()),
166166
Ok(std::path::Path::new(expected_git_dir)),
167167
"we don't skip over worktrees and discover their git dir (gitdir is absolute in file)"
168168
);

git-odb/src/alternate/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! ```
1717
//!
1818
//! Based on the [canonical implementation](https://github.com/git/git/blob/master/sha1-file.c#L598:L609).
19+
use git_path::realpath::MAX_SYMLINKS;
1920
use std::{fs, io, path::PathBuf};
2021

2122
///
@@ -45,13 +46,13 @@ pub fn resolve(objects_directory: impl Into<PathBuf>) -> Result<Vec<PathBuf>, Er
4546
let mut dirs = vec![(0, relative_base.clone())];
4647
let mut out = Vec::new();
4748
let cwd = std::env::current_dir()?;
48-
let mut seen = vec![git_path::realpath(&relative_base, &cwd)?];
49+
let mut seen = vec![git_path::realpath_opts(&relative_base, &cwd, MAX_SYMLINKS)?];
4950
while let Some((depth, dir)) = dirs.pop() {
5051
match fs::read(dir.join("info").join("alternates")) {
5152
Ok(input) => {
5253
for path in parse::content(&input)?.into_iter() {
5354
let path = relative_base.join(path);
54-
let path_canonicalized = git_path::realpath(&path, &cwd)?;
55+
let path_canonicalized = git_path::realpath_opts(&path, &cwd, MAX_SYMLINKS)?;
5556
if seen.contains(&path_canonicalized) {
5657
return Err(Error::Cycle(seen));
5758
}

git-repository/src/repository/location.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use git_path::realpath::MAX_SYMLINKS;
2+
13
impl crate::Repository {
24
/// Returns the main git repository if this is a repository on a linked work-tree, or the `git_dir` itself.
35
pub fn common_dir(&self) -> &std::path::Path {
@@ -27,7 +29,7 @@ impl crate::Repository {
2729
pub fn prefix(&self) -> Option<std::io::Result<std::path::PathBuf>> {
2830
self.work_tree.as_ref().map(|root| {
2931
std::env::current_dir().and_then(|cwd| {
30-
git_path::realpath(root, &cwd)
32+
git_path::realpath_opts(root, &cwd, MAX_SYMLINKS)
3133
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))
3234
.and_then(|root| {
3335
cwd.strip_prefix(&root)

src/porcelain/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod validator {
113113

114114
fn is_repo_inner(dir: &OsStr) -> anyhow::Result<()> {
115115
let git_dir = PathBuf::from(dir).join(".git");
116-
let p = git::path::realpath(&git_dir, std::env::current_dir()?)
116+
let p = git::path::realpath(&git_dir)
117117
.with_context(|| format!("Could not canonicalize git repository at '{}'", git_dir.display()))?;
118118
if p.extension().unwrap_or_default() == "git"
119119
|| p.file_name().unwrap_or_default() == ".git"

0 commit comments

Comments
 (0)