Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Update git2 to 0.21.0 and add support for SHA-256 object formatted repos (#57587)

Albert Boguszc3b9cacc0e90
diff --git a/Cargo.lock b/Cargo.lock
index eea3e113f85..f94dc9ab436 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7642,15 +7642,14 @@ dependencies = [
[[package]]
name = "git2"
-version = "0.20.4"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b"
+checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e"
dependencies = [
"bitflags 2.10.0",
"libc",
"libgit2-sys",
"log",
- "url",
]
[[package]]
@@ -10415,9 +10414,9 @@ dependencies = [
[[package]]
name = "libgit2-sys"
-version = "0.18.3+1.9.2"
+version = "0.18.4+1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487"
+checksum = "9b26f66f35e1871b22efcf7191564123d2a446ca0538cde63c23adfefa9b15b7"
dependencies = [
"cc",
"libc",
diff --git a/Cargo.toml b/Cargo.toml
index d3ba378098e..521128c90df 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -599,7 +599,7 @@ futures = "0.3.32"
futures-concurrency = "7.7.1"
futures-lite = "1.13"
gh-workflow = { git = "https://github.com/zed-industries/gh-workflow", rev = "37f3c0575d379c218a9c455ee67585184e40d43f" }
-git2 = { version = "0.20.1", default-features = false, features = ["vendored-libgit2"] }
+git2 = { version = "0.21.0", default-features = false, features = ["vendored-libgit2", "unstable-sha256"] }
globset = "0.4"
heapless = "0.9.2"
handlebars = "4.3"
diff --git a/crates/git/src/git.rs b/crates/git/src/git.rs
index cc3fbe1e259..73ba6275756 100644
--- a/crates/git/src/git.rs
+++ b/crates/git/src/git.rs
@@ -179,9 +179,12 @@ impl FromStr for Oid {
type Err = anyhow::Error;
fn from_str(s: &str) -> std::prelude::v1::Result<Self, Self::Err> {
- libgit::Oid::from_str(s)
- .context("parsing git oid")
- .map(Self)
+ let oid = if s.len() == 64 {
+ libgit::Oid::from_str_ext(s, libgit::ObjectFormat::Sha256)
+ } else {
+ libgit::Oid::from_str_ext(s, libgit::ObjectFormat::Sha1)
+ };
+ oid.context("parsing git oid").map(Self)
}
}
@@ -218,7 +221,7 @@ impl<'de> Deserialize<'de> for Oid {
impl Default for Oid {
fn default() -> Self {
- Self(libgit::Oid::zero())
+ Self(libgit::Oid::ZERO_SHA1)
}
}
diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs
index 6bd5e63d82d..88db950669c 100644
--- a/crates/git/src/repository.rs
+++ b/crates/git/src/repository.rs
@@ -1672,7 +1672,7 @@ impl GitRepository for RealGitRepository {
.spawn(async move {
let repo = repo.lock();
let remote = repo.find_remote(&name).ok()?;
- remote.url().map(|url| url.to_string())
+ remote.url().ok().map(|url| url.to_string())
})
.boxed()
}
diff --git a/crates/project/tests/integration/project_tests.rs b/crates/project/tests/integration/project_tests.rs
index 340d32cea13..e95e3b7e6c5 100644
--- a/crates/project/tests/integration/project_tests.rs
+++ b/crates/project/tests/integration/project_tests.rs
@@ -12738,7 +12738,7 @@ fn git_reset(offset: usize, repo: &git2::Repository) {
let new_head = commit
.parents()
.inspect(|parnet| {
- parnet.message();
+ let _ = parnet.message();
})
.nth(offset)
.expect("Not enough history");