mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
git: Silence verbose log when loading index/committed text (#50496)
Updates #50487 Release Notes: - N/A
This commit is contained in:
parent
12b786dffc
commit
7e10264219
1 changed files with 10 additions and 13 deletions
|
|
@ -1326,16 +1326,14 @@ impl GitRepository for RealGitRepository {
|
|||
if path.is_empty() {
|
||||
bail!("empty path has no index text");
|
||||
}
|
||||
let entry = index
|
||||
.get_path(path.as_std_path(), STAGE_NORMAL)
|
||||
.with_context(|| format!("looking up {path:?} in index"))?;
|
||||
let oid = if entry.mode != GIT_MODE_SYMLINK {
|
||||
entry.id
|
||||
} else {
|
||||
let Some(entry) = index.get_path(path.as_std_path(), STAGE_NORMAL) else {
|
||||
return Ok(None);
|
||||
};
|
||||
if entry.mode == GIT_MODE_SYMLINK {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let content = repo.find_blob(oid)?.content().to_owned();
|
||||
let content = repo.find_blob(entry.id)?.content().to_owned();
|
||||
Ok(String::from_utf8(content).ok())
|
||||
}
|
||||
|
||||
|
|
@ -1353,16 +1351,15 @@ impl GitRepository for RealGitRepository {
|
|||
.spawn(async move {
|
||||
fn logic(repo: &git2::Repository, path: &RepoPath) -> Result<Option<String>> {
|
||||
let head = repo.head()?.peel_to_tree()?;
|
||||
// git2 unwraps internally on empty paths or `.`
|
||||
if path.is_empty() {
|
||||
return Err(anyhow!("empty path has no committed text"));
|
||||
}
|
||||
// git2 unwraps internally on empty paths or `.`
|
||||
let entry = head.get_path(path.as_std_path())?;
|
||||
let Some(entry) = head.get_path(path.as_std_path()).ok() else {
|
||||
return Ok(None);
|
||||
};
|
||||
if entry.filemode() == i32::from(git2::FileMode::Link) {
|
||||
bail!(
|
||||
"symlink has no
|
||||
committed text"
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
let content = repo.find_blob(entry.id())?.content().to_owned();
|
||||
Ok(String::from_utf8(content).ok())
|
||||
|
|
|
|||
Loading…
Reference in a new issue