diff --git a/Cargo.lock b/Cargo.lock index 7712a40704..a58fb49f2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -656,15 +656,14 @@ dependencies = [ [[package]] name = "git2" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2b37e2f62729cdada11f0e6b3b6fe383c69c29fc619e391223e12856af308c" +checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e" dependencies = [ "bitflags 2.10.0", "libc", "libgit2-sys", "log", - "url", ] [[package]] @@ -1029,9 +1028,9 @@ checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libgit2-sys" -version = "0.18.3+1.9.2" +version = "0.18.8+1.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487" +checksum = "7f7c568b25d7489bc3fb2988ed69ab111d2944d2f5fec3d5c987fe545ea97b50" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 8f928f5bf8..ab1fe2cf84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ crossterm = "0.28.1" etcetera = "0.11.0" figment = { version = "0.10.19", features = ["toml"] } git-version = "0.3.9" -git2 = { version = "0.20.2", default-features = false } +git2 = { version = "0.21.0", default-features = false } itertools = "0.14.0" log = "0.4.28" nom = "8.0.0" diff --git a/src/git/mod.rs b/src/git/mod.rs index d65188475b..d793195bbd 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -582,7 +582,7 @@ pub(crate) fn tags(repo: &git2::Repository) -> Res> { .tag_names(None) .map_err(Error::ListGitReferences)? .into_iter() - .flatten() + .filter_map(|tag_name| tag_name.ok().flatten()) .map(|tag_name| Ref::Tag(tag_name.to_string())) .collect()) } diff --git a/src/git/tree.rs b/src/git/tree.rs index f18fe255d9..acf36fc6d9 100644 --- a/src/git/tree.rs +++ b/src/git/tree.rs @@ -138,7 +138,12 @@ pub(crate) fn tree_roots( oid: oid.to_string(), short_id: String::from_utf8_lossy(&short_id).to_string(), associated_references: references.get(oid).cloned().unwrap_or_default(), - summary: commit.summary().unwrap_or_default().to_string(), + summary: commit + .summary() + .ok() + .flatten() + .unwrap_or_default() + .to_string(), author: commit.author().name().unwrap_or_default().to_string(), age: short_age(commit.author().when()), }, diff --git a/src/item_data.rs b/src/item_data.rs index 7ee95866c8..7f05789813 100644 --- a/src/item_data.rs +++ b/src/item_data.rs @@ -159,7 +159,7 @@ impl Ref { /// Classify a reference, or `None` for ones we don't display (remote /// `HEAD` symrefs and prefetch refs). pub(crate) fn from_reference(reference: &git2::Reference) -> Option { - let name = reference.shorthand()?.to_string(); + let name = reference.shorthand().ok()?.to_string(); if name.ends_with("/HEAD") || name.starts_with("prefetch/remotes/") { return None; } diff --git a/src/items.rs b/src/items.rs index dc50398be4..bb05895bb7 100644 --- a/src/items.rs +++ b/src/items.rs @@ -123,7 +123,7 @@ pub(crate) fn stash_list(repo: &Repository, limit: usize) -> Res> { id: hash(stash_id), depth: 1, data: ItemData::Stash { - message: stash.message().unwrap_or("").to_string(), + message: stash.message().ok().flatten().unwrap_or("").to_string(), stash_ref, id: i, }, @@ -225,7 +225,7 @@ pub(crate) fn log( oid: oid.to_string(), short_id, associated_references, - summary: commit.summary().unwrap_or("").to_string(), + summary: commit.summary().ok().flatten().unwrap_or("").to_string(), author: commit.author().name().unwrap_or("").to_string(), age: short_age(commit.author().when()), }; diff --git a/src/screen/show_refs.rs b/src/screen/show_refs.rs index 4cd7483d59..881d054dc1 100644 --- a/src/screen/show_refs.rs +++ b/src/screen/show_refs.rs @@ -128,7 +128,8 @@ fn create_prefix(repo: &Repository, reference: &Reference) -> &'static str { return "? "; } - let reference_names_match = reference.name() == head.as_ref().and_then(Reference::name); + let reference_names_match = + reference.name().ok() == head.as_ref().and_then(|head| head.name().ok()); if reference_names_match { return "* ";