diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-10-04 11:13:57 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-10-04 11:24:24 +0200 |
commit | 3148efd2ee750d879493839f751fa1f80ec0612b (patch) | |
tree | 3594134fa8e1ca7ea0435ec03ad837a778ab7e3f /tests/diff/stats.c | |
parent | 1621a37dd124c6d060b2197eed01155538b0a118 (diff) | |
download | libgit2-3148efd2ee750d879493839f751fa1f80ec0612b.tar.gz |
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.
Diffstat (limited to 'tests/diff/stats.c')
-rw-r--r-- | tests/diff/stats.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/diff/stats.c b/tests/diff/stats.c index 24316f715..1149b5067 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; |