Skip to content

Commit 18e163e

Browse files
authored
Merge pull request #1823 from cruessler/add-test-for-differing-date-and-topo-order
Add test for commits not ordered chronologically
2 parents 11ac79c + a9de4f0 commit 18e163e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

gix-blame/tests/blame.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ mktest!(
236236
);
237237
mktest!(file_only_changed_in_branch, "file-only-changed-in-branch", 2);
238238
mktest!(file_changed_in_two_branches, "file-changed-in-two-branches", 3);
239+
mktest!(
240+
file_topo_order_different_than_date_order,
241+
"file-topo-order-different-than-date-order",
242+
3
243+
);
239244

240245
/// As of 2024-09-24, these tests are expected to fail.
241246
///

gix-blame/tests/fixtures/make_blame_repo.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,33 @@ git commit -q -m c14.2
198198

199199
git merge branch-that-has-one-of-the-changes || true
200200

201+
# This is to verify that, even though commits `c15`, `c15.1` and `merge` are
202+
# not chronologically ordered (`c15.1` has a `CommitDate` that is before
203+
# `c15`’s `CommitDate`), the resulting blame is still correct.
204+
#
205+
# ---c15------c15.2
206+
# \ \
207+
# c15.1----merge
208+
echo -e "line 1\nline 2\n line 3" > file-topo-order-different-than-date-order.txt
209+
git add file-topo-order-different-than-date-order.txt
210+
git commit -q -m c15
211+
212+
git checkout -b branch-that-has-earlier-commit
213+
214+
echo -e "line 1\nline 2\n line 3 changed" > file-topo-order-different-than-date-order.txt
215+
git add file-topo-order-different-than-date-order.txt
216+
# `GIT_COMMITTER_DATE` is set to "2000-01-02 00:00:00 +0000" in
217+
# `tests/tools/src/lib.rs` and is the default `CommitDate` used in
218+
# `make_blame_repo.sh`.
219+
GIT_COMMITTER_DATE="1999-12-31 00:00:00 +0000" git commit -q -m c15.1
220+
221+
git checkout main
222+
echo -e "line 1 changed\nline 2\n line 3" > file-topo-order-different-than-date-order.txt
223+
git add file-topo-order-different-than-date-order.txt
224+
git commit -q -m c15.2
225+
226+
git merge branch-that-has-earlier-commit || true
227+
201228
git blame --porcelain simple.txt > .git/simple.baseline
202229
git blame --porcelain -L 1,2 simple.txt > .git/simple-lines-1-2.baseline
203230
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
217244
git blame --porcelain different-file-in-another-chain-of-ancestors.txt > .git/different-file-in-another-chain-of-ancestors.baseline
218245
git blame --porcelain file-only-changed-in-branch.txt > .git/file-only-changed-in-branch.baseline
219246
git blame --porcelain file-changed-in-two-branches.txt > .git/file-changed-in-two-branches.baseline
247+
git blame --porcelain file-topo-order-different-than-date-order.txt > .git/file-topo-order-different-than-date-order.baseline
220248

221249
git blame --porcelain empty-lines-histogram.txt > .git/empty-lines-histogram.baseline
222250

0 commit comments

Comments
 (0)