summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-09-12 22:53:56 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-09-12 22:53:56 +0200
commita565f364aba55c730908f80e63c90d9432667075 (patch)
tree5d0ab83268d769b2a9bb61f42357a2fea24fcf19
parent493c340ceff0c2fd17deb9f5c18548771f8dd4f5 (diff)
downloadlibgit2-a565f364aba55c730908f80e63c90d9432667075.tar.gz
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
-rw-r--r--src/merge.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c
index 926a600cc..341f9a645 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2347,6 +2347,16 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
*conflicts = 0;
+ /* We need to have merged at least 1 file for the possibility to exist to
+ * have conflicts with the workdir. Passing 0 as the pathspec count paramter
+ * will consider all files in the working directory, that is, we may detect
+ * a conflict if there were untracked files in the workdir prior to starting
+ * the merge. This typically happens when cherry-picking a commmit whose
+ * changes have already been applied.
+ */
+ if (merged_paths->length == 0)
+ return 0;
+
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
/* Workdir changes may exist iff they do not conflict with changes that