diff options
author | Gregory Herrero <gregory.herrero@oracle.com> | 2019-11-07 14:10:00 +0100 |
---|---|---|
committer | Gregory Herrero <gregory.herrero@oracle.com> | 2019-11-28 14:17:50 +0100 |
commit | ece5bb5e7d6e35e50096bac3d7bf17342daaec77 (patch) | |
tree | 27f42b0b9f8fd8ac067bbfb2b780f4e72d3bae9a /tests/diff/patchid.c | |
parent | 048e94adbba3c21b9ad739640cce11a8b387df48 (diff) | |
download | libgit2-ece5bb5e7d6e35e50096bac3d7bf17342daaec77.tar.gz |
diff: make patchid computation work with all types of commits.
Current implementation of patchid is not computing a correct patchid
when given a patch where, for example, a new file is added or removed.
Some more corner cases need to be handled to have same behavior as git
patch-id command.
Add some more tests to cover those corner cases.
Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
Diffstat (limited to 'tests/diff/patchid.c')
-rw-r--r-- | tests/diff/patchid.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/diff/patchid.c b/tests/diff/patchid.c index 75a2aa814..621a720f7 100644 --- a/tests/diff/patchid.c +++ b/tests/diff/patchid.c @@ -20,6 +20,39 @@ void test_diff_patchid__simple_commit(void) verify_patch_id(PATCH_SIMPLE_COMMIT, "06094b1948b878b7d9ff7560b4eae672a014b0ec"); } +void test_diff_patchid__deleted_file(void) +{ + verify_patch_id(PATCH_DELETE_ORIGINAL, "d18507fe189f49c028b32c8c34e1ad98dd6a1aad"); + verify_patch_id(PATCH_DELETED_FILE_2_HUNKS, "f31412498a17e6c3fbc635f2c5f9aa3ef4c1a9b7"); +} + +void test_diff_patchid__created_file(void) +{ + verify_patch_id(PATCH_ADD_ORIGINAL, "a7d39379308021465ae2ce65e338c048a3110db6"); +} + +void test_diff_patchid__binary_file(void) +{ + verify_patch_id(PATCH_ADD_BINARY_NOT_PRINTED, "2b31236b485faa30cf4dd33e4d6539829996739f"); +} + +void test_diff_patchid__renamed_file(void) +{ + verify_patch_id(PATCH_RENAME_EXACT, "4666d50cea4976f6f727448046d43461912058fd"); + verify_patch_id(PATCH_RENAME_SIMILAR, "a795087575fcb940227be524488bedd6b3d3f438"); +} + +void test_diff_patchid__modechange(void) +{ + verify_patch_id(PATCH_MODECHANGE_UNCHANGED, "dbf3423ee98375ef1c72a79fbd29a049a2bae771"); + verify_patch_id(PATCH_MODECHANGE_MODIFIED, "93aba696e1bbd2bbb73e3e3e62ed71f232137657"); +} + +void test_diff_patchid__shuffle_hunks(void) +{ + verify_patch_id(PATCH_DELETED_FILE_2_HUNKS_SHUFFLED, "f31412498a17e6c3fbc635f2c5f9aa3ef4c1a9b7"); +} + void test_diff_patchid__filename_with_spaces(void) { verify_patch_id(PATCH_APPEND_NO_NL, "f0ba05413beaef743b630e796153839462ee477a"); |