diff --git a/gix-blame/tests/blame.rs b/gix-blame/tests/blame.rs index 7119bf75fa4..a4a6b4fb157 100644 --- a/gix-blame/tests/blame.rs +++ b/gix-blame/tests/blame.rs @@ -236,6 +236,11 @@ mktest!( ); mktest!(file_only_changed_in_branch, "file-only-changed-in-branch", 2); mktest!(file_changed_in_two_branches, "file-changed-in-two-branches", 3); +mktest!( + file_topo_order_different_than_date_order, + "file-topo-order-different-than-date-order", + 3 +); /// As of 2024-09-24, these tests are expected to fail. /// diff --git a/gix-blame/tests/fixtures/make_blame_repo.sh b/gix-blame/tests/fixtures/make_blame_repo.sh index ab9f46fa81a..a09a5bd73cc 100755 --- a/gix-blame/tests/fixtures/make_blame_repo.sh +++ b/gix-blame/tests/fixtures/make_blame_repo.sh @@ -198,6 +198,33 @@ git commit -q -m c14.2 git merge branch-that-has-one-of-the-changes || true +# This is to verify that, even though commits `c15`, `c15.1` and `merge` are +# not chronologically ordered (`c15.1` has a `CommitDate` that is before +# `c15`’s `CommitDate`), the resulting blame is still correct. +# +# ---c15------c15.2 +# \ \ +# c15.1----merge +echo -e "line 1\nline 2\n line 3" > file-topo-order-different-than-date-order.txt +git add file-topo-order-different-than-date-order.txt +git commit -q -m c15 + +git checkout -b branch-that-has-earlier-commit + +echo -e "line 1\nline 2\n line 3 changed" > file-topo-order-different-than-date-order.txt +git add file-topo-order-different-than-date-order.txt +# `GIT_COMMITTER_DATE` is set to "2000-01-02 00:00:00 +0000" in +# `tests/tools/src/lib.rs` and is the default `CommitDate` used in +# `make_blame_repo.sh`. +GIT_COMMITTER_DATE="1999-12-31 00:00:00 +0000" git commit -q -m c15.1 + +git checkout main +echo -e "line 1 changed\nline 2\n line 3" > file-topo-order-different-than-date-order.txt +git add file-topo-order-different-than-date-order.txt +git commit -q -m c15.2 + +git merge branch-that-has-earlier-commit || true + git blame --porcelain simple.txt > .git/simple.baseline git blame --porcelain -L 1,2 simple.txt > .git/simple-lines-1-2.baseline git blame --porcelain multiline-hunks.txt > .git/multiline-hunks.baseline @@ -217,6 +244,7 @@ git blame --porcelain file-in-one-chain-of-ancestors.txt > .git/file-in-one-chai git blame --porcelain different-file-in-another-chain-of-ancestors.txt > .git/different-file-in-another-chain-of-ancestors.baseline git blame --porcelain file-only-changed-in-branch.txt > .git/file-only-changed-in-branch.baseline git blame --porcelain file-changed-in-two-branches.txt > .git/file-changed-in-two-branches.baseline +git blame --porcelain file-topo-order-different-than-date-order.txt > .git/file-topo-order-different-than-date-order.baseline git blame --porcelain empty-lines-histogram.txt > .git/empty-lines-histogram.baseline