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.
This commit is contained in:
Patrick Steinhardt
2018-10-04 11:13:57 +02:00
parent 1621a37dd1
commit 3148efd2ee
13 changed files with 27 additions and 1 deletions

View File

@@ -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;

View File

@@ -0,0 +1,2 @@
x•ÎA
Â0@Q×9Åì™f6<11> z™tBCm-i¼¿â üû¥4°„‡VUÁS´š)Eóàœ„hET¤ëƒ|}BÊd6®º6Á<>Õ±=&§8KêÆ€<Æ<>¢dÃï6½*ܸÕfx4-ëÄulpÞöë6ï§²\ óˆ"Ñ"šôûkú¿4w]yQÈå©PVØß2j>ÄTIð

View File

@@ -1 +1 @@
5219b9784f9a92d7bd7cb567a6d6a21bfb86697e
0db2a262bc8c5c3cba55254730045a8258da7a37

View File

@@ -0,0 +1,5 @@
file2
file2
file2
file2!
file2