Skip to content

Commit 3148efd

Browse files
committed
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 parent 1621a37 commit 3148efd

13 files changed

+27
-1
lines changed

tests/diff/stats.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,25 @@ void test_diff_stats__rename_and_modifiy(void)
210210
git_buf_dispose(&buf);
211211
}
212212

213+
void test_diff_stats__rename_in_subdirectory(void)
214+
{
215+
git_buf buf = GIT_BUF_INIT;
216+
const char *stat =
217+
" dir/orig.txt => dir/renamed.txt | 0\n"
218+
" 1 file changed, 0 insertions(+), 0 deletions(-)\n";
219+
220+
diff_stats_from_commit_oid(
221+
&_stats, "0db2a262bc8c5c3cba55254730045a8258da7a37", true);
222+
223+
cl_assert_equal_sz(1, git_diff_stats_files_changed(_stats));
224+
cl_assert_equal_sz(0, git_diff_stats_insertions(_stats));
225+
cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
226+
227+
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
228+
cl_assert_equal_s(stat, git_buf_cstr(&buf));
229+
git_buf_dispose(&buf);
230+
}
231+
213232
void test_diff_stats__rename_no_find(void)
214233
{
215234
git_buf buf = GIT_BUF_INIT;
332 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/resources/diff_format_email/.gitted/objects/0d/b2a262bc8c5c3cba55254730045a8258da7a37

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x��A
2+
�0@Q�9���f�6� z��tBCm-i�����?���4���VU�S��)E����hET��|}B�d6��6����=&�9�8K�ƀ<Ɓ�d��6�*ܸՒfx4-��ulp���6鱗\��z�"�"���k��4w]yQ��PV��2�j>�TI�
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)