Skip to content

Commit 9a8126e

Browse files
jacquesgThe rugged tests are fragile
authored andcommitted
Only check for workdir conflicts if the index has merged files
Passing 0 as the length of the paths to check to git_diff_index_to_workdir results in all files being treated as conflicting, that is, all untracked or modified files in the worktree is reported as conflicting
1 parent edb2b83 commit 9a8126e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/merge.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,16 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
23512351

23522352
*conflicts = 0;
23532353

2354+
/* We need to have merged at least 1 file for the possibility to exist to
2355+
* have conflicts with the workdir. Passing 0 as the pathspec count paramter
2356+
* will consider all files in the working directory, that is, we may detect
2357+
* a conflict if there were untracked files in the workdir prior to starting
2358+
* the merge. This typically happens when cherry-picking a commmit whose
2359+
* changes have already been applied.
2360+
*/
2361+
if (merged_paths->length == 0)
2362+
return 0;
2363+
23542364
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
23552365

23562366
/* Workdir changes may exist iff they do not conflict with changes that

0 commit comments

Comments
 (0)