Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d91da1d

Browse files
committed
tests: diff::rename: use defines for commit OIDs
While we frequently reuse commit OIDs throughout the file, we do not have any constants to refer to these commits. Make this a bit easier to read by giving the commit OIDs somewhat descriptive names of what kind of commit they refer to.
1 parent 952cf71 commit d91da1d

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

tests/diff/rename.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ void test_diff_rename__cleanup(void)
1616
cl_git_sandbox_cleanup();
1717
}
1818

19+
#define INITIAL_COMMIT "31e47d8c1fa36d7f8d537b96158e3f024de0a9f2"
20+
#define COPY_RENAME_COMMIT "2bc7f351d20b53f1c72c16c4b036e491c478c49a"
21+
#define REWRITE_COPY_COMMIT "1c068dee5790ef1580cfc4cd670915b48d790084"
22+
#define RENAME_MODIFICATION_COMMIT "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13"
23+
1924
/*
2025
* Renames repo has:
2126
*
@@ -40,8 +45,8 @@ void test_diff_rename__cleanup(void)
4045

4146
void test_diff_rename__match_oid(void)
4247
{
43-
const char *old_sha = "31e47d8c1fa36d7f8d537b96158e3f024de0a9f2";
44-
const char *new_sha = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
48+
const char *old_sha = INITIAL_COMMIT;
49+
const char *new_sha = COPY_RENAME_COMMIT;
4550
git_tree *old_tree, *new_tree;
4651
git_diff *diff;
4752
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
@@ -139,8 +144,8 @@ void test_diff_rename__match_oid(void)
139144

140145
void test_diff_rename__checks_options_version(void)
141146
{
142-
const char *old_sha = "31e47d8c1fa36d7f8d537b96158e3f024de0a9f2";
143-
const char *new_sha = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
147+
const char *old_sha = INITIAL_COMMIT;
148+
const char *new_sha = COPY_RENAME_COMMIT;
144149
git_tree *old_tree, *new_tree;
145150
git_diff *diff;
146151
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
@@ -171,9 +176,9 @@ void test_diff_rename__checks_options_version(void)
171176

172177
void test_diff_rename__not_exact_match(void)
173178
{
174-
const char *sha0 = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
175-
const char *sha1 = "1c068dee5790ef1580cfc4cd670915b48d790084";
176-
const char *sha2 = "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13";
179+
const char *sha0 = COPY_RENAME_COMMIT;
180+
const char *sha1 = REWRITE_COPY_COMMIT;
181+
const char *sha2 = RENAME_MODIFICATION_COMMIT;
177182
git_tree *old_tree, *new_tree;
178183
git_diff *diff;
179184
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
@@ -433,7 +438,7 @@ void test_diff_rename__test_small_files(void)
433438

434439
void test_diff_rename__working_directory_changes(void)
435440
{
436-
const char *sha0 = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
441+
const char *sha0 = COPY_RENAME_COMMIT;
437442
const char *blobsha = "66311f5cfbe7836c27510a3ba2f43e282e2c8bba";
438443
git_oid id;
439444
git_tree *tree;
@@ -592,8 +597,8 @@ void test_diff_rename__working_directory_changes(void)
592597

593598
void test_diff_rename__patch(void)
594599
{
595-
const char *sha0 = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
596-
const char *sha1 = "1c068dee5790ef1580cfc4cd670915b48d790084";
600+
const char *sha0 = COPY_RENAME_COMMIT;
601+
const char *sha1 = REWRITE_COPY_COMMIT;
597602
git_tree *old_tree, *new_tree;
598603
git_diff *diff;
599604
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
@@ -1425,9 +1430,9 @@ void test_diff_rename__can_delete_unmodified_deltas(void)
14251430

14261431
void test_diff_rename__matches_config_behavior(void)
14271432
{
1428-
const char *sha0 = "31e47d8c1fa36d7f8d537b96158e3f024de0a9f2";
1429-
const char *sha1 = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
1430-
const char *sha2 = "1c068dee5790ef1580cfc4cd670915b48d790084";
1433+
const char *sha0 = INITIAL_COMMIT;
1434+
const char *sha1 = COPY_RENAME_COMMIT;
1435+
const char *sha2 = REWRITE_COPY_COMMIT;
14311436

14321437
git_tree *tree0, *tree1, *tree2;
14331438
git_config *cfg;
@@ -1508,8 +1513,8 @@ void test_diff_rename__matches_config_behavior(void)
15081513

15091514
void test_diff_rename__can_override_thresholds_when_obeying_config(void)
15101515
{
1511-
const char *sha1 = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
1512-
const char *sha2 = "1c068dee5790ef1580cfc4cd670915b48d790084";
1516+
const char *sha1 = COPY_RENAME_COMMIT;
1517+
const char *sha2 = REWRITE_COPY_COMMIT;
15131518

15141519
git_tree *tree1, *tree2;
15151520
git_config *cfg;
@@ -1563,8 +1568,8 @@ void test_diff_rename__can_override_thresholds_when_obeying_config(void)
15631568

15641569
void test_diff_rename__by_config_doesnt_mess_with_whitespace_settings(void)
15651570
{
1566-
const char *sha1 = "1c068dee5790ef1580cfc4cd670915b48d790084";
1567-
const char *sha2 = "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13";
1571+
const char *sha1 = REWRITE_COPY_COMMIT;
1572+
const char *sha2 = RENAME_MODIFICATION_COMMIT;
15681573

15691574
git_tree *tree1, *tree2;
15701575
git_config *cfg;
@@ -1710,8 +1715,8 @@ void test_diff_rename__blank_files_not_renamed_when_not_ignoring_whitespace(void
17101715
*/
17111716
void test_diff_rename__identical(void)
17121717
{
1713-
const char *old_sha = "31e47d8c1fa36d7f8d537b96158e3f024de0a9f2";
1714-
const char *new_sha = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
1718+
const char *old_sha = INITIAL_COMMIT;
1719+
const char *new_sha = COPY_RENAME_COMMIT;
17151720
git_tree *old_tree, *new_tree;
17161721
git_diff *diff;
17171722
git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;

0 commit comments

Comments
 (0)