1026
return ret < 0 ? ret : 0;
1027
}
1028
1029
-static void setup_path_info(struct merge_options *opt,
1030
- struct string_list_item *result,
1031
- const char *current_dir_name,
1032
- int current_dir_name_len,
1033
- char *fullpath, /* we'll take over ownership */
1034
- struct name_entry *names,
1035
- struct name_entry *merged_version,
1036
- unsigned is_null, /* boolean */
1037
- unsigned df_conflict, /* boolean */
1038
- unsigned filemask,
1039
- unsigned dirmask,
1040
- int resolved /* boolean */)
1029
+static int setup_path_info(struct merge_options *opt,
1030
+ struct string_list_item *result,
1031
+ const char *current_dir_name,
1032
+ int current_dir_name_len,
1033
+ char *fullpath, /* we'll take over ownership */
1034
+ struct name_entry *names,
1035
+ struct name_entry *merged_version,
1036
+ unsigned is_null, /* boolean */
1037
+ unsigned df_conflict, /* boolean */
1038
+ unsigned filemask,
1039
+ unsigned dirmask,
1040
+ int resolved /* boolean */)
1041
{
1042
/* result->util is void*, so mi is a convenience typed variable */
1043
struct merged_info *mi;
1081
*/
1082
mi->is_null = 1;
1083
}
1084
- strmap_put(&opt->priv->paths, fullpath, mi);
1084
+ if (strmap_put(&opt->priv->paths, fullpath, mi))
1085
+ return error(_("tree has duplicate entries for '%s'"), fullpath);
1086
result->string = fullpath;
1087
result->util = mi;
1088
+ return 0;
1089
}
1090
1091
static void add_pair(struct merge_options *opt,
1352
*/
1353
if (side1_matches_mbase && side2_matches_mbase) {
1354
/* mbase, side1, & side2 all match; use mbase as resolution */
1353
- setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1354
- names, names+0, mbase_null, 0 /* df_conflict */,
1355
- filemask, dirmask, 1 /* resolved */);
1355
+ if (setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1356
+ names, names+0, mbase_null, 0 /* df_conflict */,
1357
+ filemask, dirmask, 1 /* resolved */))
1358
+ return -1; /* Quit traversing */
1359
return mask;
1360
}
1361
1367
*/
1368
if (sides_match && filemask == 0x07) {
1369
/* use side1 (== side2) version as resolution */
1367
- setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1368
- names, names+1, side1_null, 0,
1369
- filemask, dirmask, 1);
1370
+ if (setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1371
+ names, names+1, side1_null, 0,
1372
+ filemask, dirmask, 1))
1373
+ return -1; /* Quit traversing */
1374
return mask;
1375
}
1376
1382
*/
1383
if (side1_matches_mbase && filemask == 0x07) {
1384
/* use side2 version as resolution */
1381
- setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1382
- names, names+2, side2_null, 0,
1383
- filemask, dirmask, 1);
1385
+ if (setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1386
+ names, names+2, side2_null, 0,
1387
+ filemask, dirmask, 1))
1388
+ return -1; /* Quit traversing */
1389
return mask;
1390
}
1391
1392
/* Similar to above but swapping sides 1 and 2 */
1393
if (side2_matches_mbase && filemask == 0x07) {
1394
/* use side1 version as resolution */
1390
- setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1391
- names, names+1, side1_null, 0,
1392
- filemask, dirmask, 1);
1395
+ if (setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1396
+ names, names+1, side1_null, 0,
1397
+ filemask, dirmask, 1))
1398
+ return -1; /* Quit traversing */
1399
return mask;
1400
}
1401
1419
* unconflict some more cases, but that comes later so all we can
1420
* do now is record the different non-null file hashes.)
1421
*/
1416
- setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1417
- names, NULL, 0, df_conflict, filemask, dirmask, 0);
1422
+ if (setup_path_info(opt, &pi, dirname, info->pathlen, fullpath,
1423
+ names, NULL, 0, df_conflict, filemask, dirmask, 0))
1424
+ return -1; /* Quit traversing */
1425
1426
ci = pi.util;
1427
VERIFY_CI(ci);