Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix searching for full SHA-256 commit hashes in Git graph (#63371)
Albert Bogusz1662f5f3f649
diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rsindex 70b17bd7084..72ecb59f90c 100644--- a/crates/git/src/repository.rs+++ b/crates/git/src/repository.rs@@ -3,7 +3,7 @@ use crate::stash::GitStash;use crate::status::{DiffTreeType, FileStatus, GitStatus, StatusCode, TrackedStatus, TreeDiff, TreeDiffStatus,};-use crate::{Oid, RunHook, SHORT_SHA_LENGTH};+use crate::{Oid, RunHook, SHA256_HEX_LENGTH, SHORT_SHA_LENGTH};use anyhow::{Context as _, Result, anyhow, bail};use async_channel::Sender;use collections::HashMap;@@ -764,7 +764,7 @@ pub struct SearchCommitArgs {pub fn commit_hash_search_query(query: &str) -> Option<&str> {let query = query.trim();- (7..=40)+ (SHORT_SHA_LENGTH..=SHA256_HEX_LENGTH).contains(&query.len()).then_some(query).filter(|query| query.bytes().all(|byte| byte.is_ascii_hexdigit()))@@ -4273,6 +4273,26 @@ mod tests {use super::*;use gpui::TestAppContext;+ #[test]+ fn test_commit_hash_search_query_accepts_sha1_and_sha256_hashes() {+ assert_eq!(+ commit_hash_search_query("0123456789abcdef0123456789abcdef01234567"),+ Some("0123456789abcdef0123456789abcdef01234567")+ );+ assert_eq!(+ commit_hash_search_query(+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ ),+ Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")+ );+ assert_eq!(+ commit_hash_search_query(+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0"+ ),+ None+ );+ }+fn disable_git_global_config() {unsafe {std::env::set_var("GIT_CONFIG_GLOBAL", "");