MCPcopy Create free account
hub / github.com/git/git / handle_path_level_conflicts

Function handle_path_level_conflicts

merge-ort.c:2384–2455  ·  view source on GitHub ↗

* See if there is a directory rename for path, and if there are any file * level conflicts on the given side for the renamed location. If there is * a rename and there are no conflicts, return the new name. Otherwise, * return NULL. */

Source from the content-addressed store, hash-verified

2382 * return NULL.
2383 */
2384static char *handle_path_level_conflicts(struct merge_options *opt,
2385 const char *path,
2386 unsigned side_index,
2387 struct diff_filepair *p,
2388 struct strmap_entry *rename_info,
2389 struct strmap *collisions)
2390{
2391 char *new_path = NULL;
2392 struct collision_info *c_info;
2393 int clean = 1;
2394 struct strbuf collision_paths = STRBUF_INIT;
2395
2396 /*
2397 * entry has the mapping of old directory name to new directory name
2398 * that we want to apply to path.
2399 */
2400 new_path = apply_dir_rename(rename_info, path);
2401 if (!new_path)
2402 BUG("Failed to apply directory rename!");
2403
2404 /*
2405 * The caller needs to have ensured that it has pre-populated
2406 * collisions with all paths that map to new_path. Do a quick check
2407 * to ensure that's the case.
2408 */
2409 c_info = strmap_get(collisions, new_path);
2410 if (!c_info)
2411 BUG("c_info is NULL");
2412
2413 /*
2414 * Check for one-sided add/add/.../add conflicts, i.e.
2415 * where implicit renames from the other side doing
2416 * directory rename(s) can affect this side of history
2417 * to put multiple paths into the same location. Warn
2418 * and bail on directory renames for such paths.
2419 */
2420 if (c_info->reported_already) {
2421 clean = 0;
2422 } else if (path_in_way(&opt->priv->paths, new_path, 1 << side_index, p)) {
2423 c_info->reported_already = 1;
2424 strbuf_add_separated_string_list(&collision_paths, ", ",
2425 &c_info->source_files);
2426 path_msg(opt, CONFLICT_DIR_RENAME_FILE_IN_WAY, 0,
2427 new_path, NULL, NULL, &c_info->source_files,
2428 _("CONFLICT (implicit dir rename): Existing "
2429 "file/dir at %s in the way of implicit "
2430 "directory rename(s) putting the following "
2431 "path(s) there: %s."),
2432 new_path, collision_paths.buf);
2433 clean = 0;
2434 } else if (c_info->source_files.nr > 1) {
2435 c_info->reported_already = 1;
2436 strbuf_add_separated_string_list(&collision_paths, ", ",
2437 &c_info->source_files);
2438 path_msg(opt, CONFLICT_DIR_RENAME_COLLISION, 0,
2439 new_path, NULL, NULL, &c_info->source_files,
2440 _("CONFLICT (implicit dir rename): Cannot map "
2441 "more than one path to %s; implicit directory "

Callers 1

Calls 6

apply_dir_renameFunction · 0.85
strmap_getFunction · 0.85
path_in_wayFunction · 0.85
path_msgFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected