664
return strbuf_detach(&newpath, NULL);
665
}
666
667
-static int dir_in_way(const char *path, int check_working_copy)
667
+/**
668
+ * Check whether a directory in the index is in the way of an incoming
669
+ * file. Return 1 if so. If check_working_copy is non-zero, also
670
+ * check the working directory. If empty_ok is non-zero, also return
671
+ * 0 in the case where the working-tree dir exists but is empty.
672
+ */
673
+static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
674
{
675
int pos;
676
struct strbuf dirpath = STRBUF_INIT;
690
}
691
692
strbuf_release(&dirpath);
687
- return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode);
693
+ return check_working_copy && !lstat(path, &st) && S_ISDIR(st.st_mode) &&
694
+ !(empty_ok && is_empty_dir(path));
695
}
696
697
static int was_tracked(const char *path)
1069
{
1070
char *renamed = NULL;
1071
int ret = 0;
1065
- if (dir_in_way(path, !o->call_depth)) {
1072
+ if (dir_in_way(path, !o->call_depth, 0)) {
1073
renamed = unique_path(o, path, a_oid ? o->branch1 : o->branch2);
1074
}
1075
1202
remove_file(o, 0, rename->path, 0);
1203
dst_name = unique_path(o, rename->path, cur_branch);
1204
} else {
1198
- if (dir_in_way(rename->path, !o->call_depth)) {
1205
+ if (dir_in_way(rename->path, !o->call_depth, 0)) {
1206
dst_name = unique_path(o, rename->path, cur_branch);
1207
output(o, 1, _("%s is a directory in %s adding as %s instead"),
1208
rename->path, other_branch, dst_name);
1711
o->branch2 == rename_conflict_info->branch1) ?
1712
pair1->two->path : pair1->one->path;
1713
1707
- if (dir_in_way(path, !o->call_depth))
1714
+ if (dir_in_way(path, !o->call_depth,
1715
+ S_ISGITLINK(pair1->two->mode)))
1716
df_conflict_remains = 1;
1717
}
1718
if (merge_file_special_markers(o, &one, &a, &b,
1870
oid = b_oid;
1871
conf = _("directory/file");
1872
}
1865
- if (dir_in_way(path, !o->call_depth)) {
1873
+ if (dir_in_way(path, !o->call_depth,
1874
+ S_ISGITLINK(a_mode))) {
1875
char *new_path = unique_path(o, path, add_branch);
1876
clean_merge = 0;
1877
output(o, 1, _("CONFLICT (%s): There is a directory with name %s in %s. "