forge
Explore
Log in

Don't you dare go Hollow

The last-commit walk counts every commit it visits, so a rarely changed directory can no longer walk a huge history

Browse files at this commit

28e31436ed86500092a942764d6197d108731db2Ahmet Kaan GümüşParent: c25199e
Some checks failed
Show checks
  • fix
    • the last-commit walk counts every commit it visits, so a rarely changed directory can no longer walk a huge history
    • the cap is 10 000 commits
Show full message
🐛 fix: the last-commit walk counts every commit it visits, so a rarely changed directory can no longer walk a huge history; the cap is 10 000 commits
crates/forge-git/src/history.rsmodified+1 -1
@@ -912,6 +912,7 @@ fn last_commits_blocking(
912912 if walked == max_walk || found.len() == wanted.len() {
913913 break;
914914 }
915+ walked += 1;
915916 let id = info.map_err(browse::gerr)?.id;
916917 let object = repo.find_commit(id).map_err(browse::gerr)?;
917918 let parents: Vec<gix::ObjectId> = object.parent_ids().map(|p| p.detach()).collect();
@@ -933,7 +934,6 @@ fn last_commits_blocking(
933934 if cur.as_ref().map(|t| t.id().detach()) == prev.as_ref().map(|t| t.id().detach()) {
934935 continue;
935936 }
936- walked += 1;
937937 let cur = dir_entries(cur, wanted)?;
938938 let prev = dir_entries(prev, wanted)?;
939939 let changed: Vec<String> = wanted
crates/forge-git/tests/integration/history.rsmodified+1 -1
@@ -235,7 +235,7 @@ async fn last_commits_finds_newest_touch_per_child() {
235235 assert_eq!(root["d"].oid, c5);
236236 assert_eq!(root["other.txt"].oid, c6);
237237
238- let short = last_commits(&f.git_dir, &c6, "d", &names, 1).await.unwrap();
238+ let short = last_commits(&f.git_dir, &c6, "d", &names, 2).await.unwrap();
239239 assert_eq!(short.len(), 1);
240240 assert_eq!(short["sub"].oid, c5);
241241 }
crates/forge-web-pages/src/pages/tree.rsmodified+1 -1
@@ -40,7 +40,7 @@ pub const README_NAMES: [&str; 5] = [
4040 ];
4141
4242 pub const MAX_BLOB_BYTES: usize = 1 << 20;
43-const LAST_COMMIT_WALK: usize = 2000;
43+const LAST_COMMIT_WALK: usize = 10_000;
4444 const LAST_COMMIT_TIMEOUT: Duration = Duration::from_secs(3);
4545
4646 path_param!(owner);