Skip to content

Add test for commits not ordered chronologically #1823

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gix-blame/tests/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
28 changes: 28 additions & 0 deletions gix-blame/tests/fixtures/make_blame_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading