tests: verify diff stats with renames in subdirectory Until now, we didn't have any tests that verified that our format for renames in subdirectories is correct. While our current behaviour is no different than for renames that do not happen with a common prefix shared between old and new file name, we intend to change the format to instead match the format that upstream git uses. Add a test case for this to document our current behaviour and to show how the next commit will change that format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 24316f7..1149b50 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -210,6 +210,25 @@ void test_diff_stats__rename_and_modifiy(void)
git_buf_dispose(&buf);
}
+void test_diff_stats__rename_in_subdirectory(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+ const char *stat =
+ " dir/orig.txt => dir/renamed.txt | 0\n"
+ " 1 file changed, 0 insertions(+), 0 deletions(-)\n";
+
+ diff_stats_from_commit_oid(
+ &_stats, "0db2a262bc8c5c3cba55254730045a8258da7a37", true);
+
+ cl_assert_equal_sz(1, git_diff_stats_files_changed(_stats));
+ cl_assert_equal_sz(0, git_diff_stats_insertions(_stats));
+ cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
+
+ cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
+ cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ git_buf_dispose(&buf);
+}
+
void test_diff_stats__rename_no_find(void)
{
git_buf buf = GIT_BUF_INIT;
diff --git a/tests/resources/diff_format_email/.gitted/index b/tests/resources/diff_format_email/.gitted/index
index 092a888..4514a6b 100644
Binary files a/tests/resources/diff_format_email/.gitted/index and b/tests/resources/diff_format_email/.gitted/index differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/07/594f324ebcf92902334c6016e30e716431dfbc b/tests/resources/diff_format_email/.gitted/objects/07/594f324ebcf92902334c6016e30e716431dfbc
new file mode 100644
index 0000000..bd27379
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/07/594f324ebcf92902334c6016e30e716431dfbc differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/0d/593fca18d1ab11deb6e8025c9fe417456fe883 b/tests/resources/diff_format_email/.gitted/objects/0d/593fca18d1ab11deb6e8025c9fe417456fe883
new file mode 100644
index 0000000..e49e107
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/0d/593fca18d1ab11deb6e8025c9fe417456fe883 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/0d/b2a262bc8c5c3cba55254730045a8258da7a37 b/tests/resources/diff_format_email/.gitted/objects/0d/b2a262bc8c5c3cba55254730045a8258da7a37
new file mode 100644
index 0000000..1399d7f
--- /dev/null
+++ b/tests/resources/diff_format_email/.gitted/objects/0d/b2a262bc8c5c3cba55254730045a8258da7a37
@@ -0,0 +1,2 @@
+xA
+0@Q9f6 ztBCm-i
?4VUS)EhET|}Bd66=&98Kƀ<Ɓd6*ܸՒfx4-ulp6鱗\z""k4w]yQPV2j>TI
\ No newline at end of file
diff --git a/tests/resources/diff_format_email/.gitted/objects/39/ed6bbd76bca81c50db3aaca261456284f5d5b8 b/tests/resources/diff_format_email/.gitted/objects/39/ed6bbd76bca81c50db3aaca261456284f5d5b8
new file mode 100644
index 0000000..e08f03c
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/39/ed6bbd76bca81c50db3aaca261456284f5d5b8 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/53/92ef3c959f744b892bbebb168bbbb7b05c03f3 b/tests/resources/diff_format_email/.gitted/objects/53/92ef3c959f744b892bbebb168bbbb7b05c03f3
new file mode 100644
index 0000000..308c599
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/53/92ef3c959f744b892bbebb168bbbb7b05c03f3 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/85/fa91713734c588c897dd6dd67a39576f67ae50 b/tests/resources/diff_format_email/.gitted/objects/85/fa91713734c588c897dd6dd67a39576f67ae50
new file mode 100644
index 0000000..54d3412
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/85/fa91713734c588c897dd6dd67a39576f67ae50 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/8c/637df9661edd808932b2f5d383f2c41ced9f06 b/tests/resources/diff_format_email/.gitted/objects/8c/637df9661edd808932b2f5d383f2c41ced9f06
new file mode 100644
index 0000000..e7d672b
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/8c/637df9661edd808932b2f5d383f2c41ced9f06 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/94/f84b3e65e8bcbe8bffef2c885339343a802dd4 b/tests/resources/diff_format_email/.gitted/objects/94/f84b3e65e8bcbe8bffef2c885339343a802dd4
new file mode 100644
index 0000000..03b4848
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/94/f84b3e65e8bcbe8bffef2c885339343a802dd4 differ
diff --git a/tests/resources/diff_format_email/.gitted/objects/bb/07a00e58b260c4eb9a82f8afbc1d80ad9739bf b/tests/resources/diff_format_email/.gitted/objects/bb/07a00e58b260c4eb9a82f8afbc1d80ad9739bf
new file mode 100644
index 0000000..d2cb6d0
Binary files /dev/null and b/tests/resources/diff_format_email/.gitted/objects/bb/07a00e58b260c4eb9a82f8afbc1d80ad9739bf differ
diff --git a/tests/resources/diff_format_email/.gitted/refs/heads/master b/tests/resources/diff_format_email/.gitted/refs/heads/master
index 4024b97..7d5e03f 100644
--- a/tests/resources/diff_format_email/.gitted/refs/heads/master
+++ b/tests/resources/diff_format_email/.gitted/refs/heads/master
@@ -1 +1 @@
-5219b9784f9a92d7bd7cb567a6d6a21bfb86697e
+0db2a262bc8c5c3cba55254730045a8258da7a37
diff --git a/tests/resources/diff_format_email/dir/renamed.txt b/tests/resources/diff_format_email/dir/renamed.txt
new file mode 100644
index 0000000..7aff11d
--- /dev/null
+++ b/tests/resources/diff_format_email/dir/renamed.txt
@@ -0,0 +1,5 @@
+file2
+file2
+file2
+file2!
+file2