From bd54a51205beb2aa71f8d4efb9b0749f425fb1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Tue, 21 Jun 2022 20:03:49 +0200 Subject: Fix whole-file changes being attributed to the wrong commit in "git log" output The pending buffer for whole-file changes is currently only flushed when encountering a new diff header. This leads to it being carried over across commit boundaries in cases where multiple commits are shown. To fix this, we simply need to flush the buffered data on a commit boundary as well. Fixes #1089 --- src/tests/test_example_diffs.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/tests/test_example_diffs.rs') diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index 325f2e9..d3800a6 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -1626,6 +1626,13 @@ src/align.rs:71: impl<'a> Alignment<'a> { │ .expect_contains("a b ⟶ c d\n"); } + #[test] + fn test_file_removal_in_log_output() { + DeltaTest::with_args(&[]) + .with_input(GIT_LOG_FILE_REMOVAL_IN_FIRST_COMMIT) + .expect_after_header("#partial\n\nremoved: a"); + } + const GIT_DIFF_SINGLE_HUNK: &str = "\ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e Author: Dan Davison @@ -2385,5 +2392,27 @@ index d00491f..0cfbf08 100644 @@ -1 +1 @@ -1 +2 +"; + + const GIT_LOG_FILE_REMOVAL_IN_FIRST_COMMIT: &str = " +commit 4117f616160180c0c57ea64840eadd08b7fa32a4 +Author: Björn Steinbrink +Date: Tue Jun 21 14:51:59 2022 +0200 + + remove file + +diff --git a a +deleted file mode 100644 +index e69de29..0000000 + +commit 190cce5dffeb9050fd6a27780f16d84b19c07dc0 +Author: Björn Steinbrink +Date: Tue Jun 21 14:48:20 2022 +0200 + + add file + +diff --git a a +new file mode 100644 +index 0000000..e69de29 "; } -- cgit v1.2.3