-
Notifications
You must be signed in to change notification settings - Fork 436
feat: Git recency bonuses #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,22 @@ use std::{ | |
| path::{Path, PathBuf}, | ||
| }; | ||
|
|
||
| /// Process-wide libgit2 tuning for read-heavy local use. By default libgit2 | ||
| /// never caches trees over 4KB (large repos re-inflate every directory tree on | ||
| /// every diff) and SHA-verifies each object read; measured on chromium this | ||
| /// takes a 10-commit recency walk from 1.4s down to 0.56s. | ||
| pub(crate) fn tune_libgit2_for_local_reads() { | ||
| static TUNE: std::sync::Once = std::sync::Once::new(); | ||
| TUNE.call_once(|| { | ||
| // Same tradeoff cargo makes: local objects are trusted, skip hashing. | ||
| git2::opts::strict_hash_verification(false); | ||
| // SAFETY: plain process-global size limit; total memory stays bounded | ||
| // by libgit2's 256MB odb cache. | ||
| let _ = | ||
| unsafe { git2::opts::set_cache_object_limit(git2::ObjectType::Tree, 8 * 1024 * 1024) }; | ||
| }); | ||
| } | ||
|
Comment on lines
+13
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- git.rs ---'
cat -n crates/fff-core/src/git.rs | sed -n '1,180p'
printf '%s\n' '--- direct callers ---'
rg -n -C 4 'tune_libgit2_for_local_reads|FilePicker::new' crates/fff-core/src
printf '%s\n' '--- dependency declarations ---'
rg -n -C 3 'git2|libgit2' Cargo.toml Cargo.lock cratesRepository: dmtrKovalenko/fff Length of output: 50375 🤖 get_repo_knowledge executed:
Length of output: 17860 Security Misconfiguration (CWE-354) Reachability: External · Exploitability: Difficult Keep libgit2 hash verification enabled Remove 🤖 Prompt for AI Agents |
||
|
|
||
| pub(crate) fn default_status_options() -> StatusOptions { | ||
| let mut opts = StatusOptions::new(); | ||
| opts.include_untracked(true) | ||
|
|
@@ -52,7 +68,10 @@ impl GitStatusCache { | |
| } | ||
|
|
||
| #[tracing::instrument(skip(repo, status_options))] | ||
| fn read_status_impl(repo: &Repository, status_options: &mut StatusOptions) -> Result<Self> { | ||
| pub(crate) fn read_status( | ||
| repo: &Repository, | ||
| status_options: &mut StatusOptions, | ||
| ) -> Result<Self> { | ||
| let statuses = repo.statuses(Some(status_options))?; | ||
| let Some(repo_path) = repo.workdir() else { | ||
| return Ok(Self(AHashMap::new())); // repo is bare | ||
|
|
@@ -80,7 +99,7 @@ impl GitStatusCache { | |
| let git_workdir = git_workdir.as_ref()?; | ||
| let repository = Repository::open(git_workdir).ok()?; | ||
|
|
||
| let status = Self::read_status_impl(&repository, status_options); | ||
| let status = Self::read_status(&repository, status_options); | ||
|
|
||
| match status { | ||
| Ok(status) => Some(status), | ||
|
|
@@ -123,7 +142,7 @@ impl GitStatusCache { | |
| status_options.pathspec(path.as_ref().strip_prefix(&workdir)?); | ||
| } | ||
|
|
||
| let git_status_cache = Self::read_status_impl(repo, &mut status_options)?; | ||
| let git_status_cache = Self::read_status(repo, &mut status_options)?; | ||
| Ok(git_status_cache) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: dmtrKovalenko/fff
Length of output: 1143
🏁 Script executed:
Repository: dmtrKovalenko/fff
Length of output: 50376
🤖 get_repo_knowledge executed:
get_repo_knowledge dmtrKovalenko/fff /tmp/coderabbit-repo-knowledge/dmtrkovalenko-fff-64a975e7/architecture /tmp/coderabbit-repo-knowledge/dmtrkovalenko-fff-64a975e7/conventionsLength of output: 22485
Treat this as a breaking API change.
fff-searchexposesFilePickerOptionswith public fields. Adding requiredgit_recencymakes existing downstream struct literals fail to compile. Update supported consumers and publish this in a breaking release.🤖 Prompt for AI Agents