Skip to content

Commit edb2b83

Browse files
jacquesgThe rugged tests are fragile
authored andcommitted
Added test case to illustrate bogus conflicts detected if no files were merged, and untracked files exist in the workdir.
1 parent c93d1eb commit edb2b83

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/cherrypick/workdir.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,47 @@ void test_cherrypick_workdir__automerge(void)
9292
git_signature_free(signature);
9393
}
9494

95+
/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15
96+
* git cherry-pick a43a050c588d4e92f11a6b139680923e9728477d*/
97+
void test_cherrypick_workdir__empty_result(void)
98+
{
99+
git_oid head_oid;
100+
git_signature *signature = NULL;
101+
git_commit *head = NULL, *commit = NULL;
102+
git_oid cherry_oid;
103+
104+
const char *cherrypick_oid = "a43a050c588d4e92f11a6b139680923e9728477d";
105+
106+
struct merge_index_entry merge_index_entries[] = {
107+
{ 0100644, "19c5c7207054604b69c84d08a7571ef9672bb5c2", 0, "file1.txt" },
108+
{ 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 0, "file2.txt" },
109+
{ 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 0, "file3.txt" },
110+
};
111+
112+
cl_git_pass(git_signature_new(&signature, "Picker", "picker@example.org", time(NULL), 0));
113+
114+
git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
115+
116+
/* Create an untracked file that should not conflict */
117+
cl_git_mkfile(TEST_REPO_PATH "/file4.txt", "");
118+
cl_assert(git_path_exists(TEST_REPO_PATH "/file4.txt"));
119+
120+
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
121+
cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
122+
123+
git_oid_fromstr(&cherry_oid, cherrypick_oid);
124+
cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
125+
cl_git_pass(git_cherrypick(repo, commit, NULL));
126+
127+
/* The resulting tree should not have changed, the change was already on HEAD */
128+
cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
129+
130+
git_commit_free(head);
131+
git_commit_free(commit);
132+
133+
git_signature_free(signature);
134+
}
135+
95136
/* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8
96137
* git cherry-pick e9b63f3655b2ad80c0ff587389b5a9589a3a7110
97138
*/

0 commit comments

Comments
 (0)