merge-ort: step 1 of tree writing -- record basenames, modes, and oids
As a step towards transforming the processed path->conflict_info entries into an actual tree object, start recording basenames, modes, and oids in a dir_metadata structure. Subsequent commits will make use of this to actually write a tree. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Dec 13, 2020 at 08:04 UTC
a9945bba600914bc8feb7aa52dce7b8e41237649
1 file changed
+37
-3
merge-ort.c
+37
-3
@@ -519,10 +519,31 @@ static int string_list_df_name_compare(const char *one, const char *two)
519
return onelen - twolen;
520
}
521
522
+struct directory_versions {
523
+ struct string_list versions;
524
+};
525
+
526
+static void record_entry_for_tree(struct directory_versions *dir_metadata,
527
+ const char *path,
528
+ struct merged_info *mi)
529
+{
530
+ const char *basename;
531
+
532
+ if (mi->is_null)
533
+ /* nothing to record */
534
+ return;
535
+
536
+ basename = path + mi->basename_offset;
537
+ assert(strchr(basename, '/') == NULL);
538
+ string_list_append(&dir_metadata->versions,
539
+ basename)->util = &mi->result;
540
+}
541
+
542
/* Per entry merge function */
543
static void process_entry(struct merge_options *opt,
544
const char *path,
525
- struct conflict_info *ci)
545
+ struct conflict_info *ci,
546
+ struct directory_versions *dir_metadata)
547
{
548
VERIFY_CI(ci);
549
assert(ci->filemask >= 0 && ci->filemask <= 7);
@@ -530,6 +551,14 @@ static void process_entry(struct merge_options *opt,
551
assert(ci->match_mask == 0 || ci->match_mask == 3 ||
552
ci->match_mask == 5 || ci->match_mask == 6);
553
554
+ if (ci->dirmask) {
555
+ record_entry_for_tree(dir_metadata, path, &ci->merged);
556
+ if (ci->filemask == 0)
557
+ /* nothing else to handle */
558
+ return;
559
+ assert(ci->df_conflict);
560
+ }
561
+
562
if (ci->df_conflict) {
563
die("Not yet implemented.");
564
}
@@ -598,6 +627,7 @@ static void process_entry(struct merge_options *opt,
627
*/
628
if (!ci->merged.clean)
629
strmap_put(&opt->priv->conflicted, path, ci);
630
+ record_entry_for_tree(dir_metadata, path, &ci->merged);
631
}
632
633
static void process_entries(struct merge_options *opt,
@@ -607,6 +637,7 @@ static void process_entries(struct merge_options *opt,
637
struct strmap_entry *e;
638
struct string_list plist = STRING_LIST_INIT_NODUP;
639
struct string_list_item *entry;
640
+ struct directory_versions dir_metadata = { STRING_LIST_INIT_NODUP };
641
642
if (strmap_empty(&opt->priv->paths)) {
643
oidcpy(result_oid, opt->repo->hash_algo->empty_tree);
@@ -636,13 +667,16 @@ static void process_entries(struct merge_options *opt,
667
*/
668
struct merged_info *mi = entry->util;
669
639
- if (!mi->clean) {
670
+ if (mi->clean)
671
+ record_entry_for_tree(&dir_metadata, path, mi);
672
+ else {
673
struct conflict_info *ci = (struct conflict_info *)mi;
641
- process_entry(opt, path, ci);
674
+ process_entry(opt, path, ci, &dir_metadata);
675
}
676
}
677
678
string_list_clear(&plist, 0);
679
+ string_list_clear(&dir_metadata.versions, 0);
680
die("Tree creation not yet implemented");
681
}
682