diff --git a/src/info/git/mod.rs b/src/info/git/mod.rs index 3e144b3bb..741a24c50 100644 --- a/src/info/git/mod.rs +++ b/src/info/git/mod.rs @@ -249,6 +249,7 @@ fn compute_diff_with_parent( .into_tree() .changes()? .track_path() + .track_rewrites(None) .for_each_to_obtain_tree(&commit.tree()?, |change| { let is_file_change = match change.event { Event::Addition { entry_mode, .. } | Event::Modification { entry_mode, .. } => { diff --git a/tests/fixtures/make_partial_repo.sh b/tests/fixtures/make_partial_repo.sh new file mode 100644 index 000000000..67d067aeb --- /dev/null +++ b/tests/fixtures/make_partial_repo.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -eu -o pipefail + +mkdir base +(cd base + git init -q + git checkout -b main + touch code.rs + git add code.rs + git commit -q -m c1 + echo hello >> code.rs + git add code.rs + git commit -q -m c2 + echo world >> code.rs + git add code.rs + git commit -q -m c3 + echo something >> code.rs + git add code.rs + git commit -q -m c4 + echo more >> code.rs + git mv code.rs renamed.rs + echo change >> renamed.rs + git commit -q -am c5 + + git config uploadpack.allowfilter true +) + +git clone --filter=blob:none file://$PWD/base partial +(cd partial + git config diff.renames true +) diff --git a/tests/repo.rs b/tests/repo.rs index da73d4f5d..988954cb4 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -4,12 +4,19 @@ use onefetch::cli::{CliOptions, InfoCliOptions, TextForamttingCliOptions}; use onefetch::info::{build_info, get_work_dir}; fn repo(name: &str) -> Result { - let name = name.to_string(); let repo_path = gix_testtools::scripted_fixture_read_only(name).unwrap(); let safe_repo = ThreadSafeRepository::open_opts(repo_path, open::Options::isolated())?; Ok(safe_repo.to_thread_local()) } +pub fn named_repo(fixture: &str, name: &str) -> Result { + let repo_path = gix_testtools::scripted_fixture_read_only(fixture) + .unwrap() + .join(name); + let safe_repo = ThreadSafeRepository::open_opts(repo_path, open::Options::isolated())?; + Ok(safe_repo.to_thread_local()) +} + #[test] fn test_bare_repo() -> Result<()> { let repo = repo("bare_repo.sh")?; @@ -65,3 +72,14 @@ fn test_repo_without_remote() -> Result<()> { Ok(()) } + +#[test] +fn test_partial_repo() -> Result<()> { + let repo = named_repo("make_partial_repo.sh", "partial")?; + let config: CliOptions = CliOptions { + input: repo.path().to_path_buf(), + ..Default::default() + }; + let _info = build_info(&config).expect("no error"); + Ok(()) +}