Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2022-06-18 03:20:50 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-23 02:10:06 +0300
commitfae26ce79cad6d290e296e40f2d46eb783e91110 (patch)
treebf5e449ec20ff735b92c615c81d5fc30145529c3 /merge-ort.c
parenta1a7811975e4e3d872379ab03acab9506933de9c (diff)
merge-ort: provide a merge_get_conflicted_files() helper function
After a merge, this function allows the user to extract the same information that would be printed by `ls-files -u`, which means files with their mode, oid, and stage. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 3c6d0577de..bc1fcad8b4 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4296,6 +4296,37 @@ void merge_display_update_messages(struct merge_options *opt,
trace2_region_leave("merge", "display messages", opt->repo);
}
+void merge_get_conflicted_files(struct merge_result *result,
+ struct string_list *conflicted_files)
+{
+ struct hashmap_iter iter;
+ struct strmap_entry *e;
+ struct merge_options_internal *opti = result->priv;
+
+ strmap_for_each_entry(&opti->conflicted, &iter, e) {
+ const char *path = e->key;
+ struct conflict_info *ci = e->value;
+ int i;
+
+ VERIFY_CI(ci);
+
+ for (i = MERGE_BASE; i <= MERGE_SIDE2; i++) {
+ struct stage_info *si;
+
+ if (!(ci->filemask & (1ul << i)))
+ continue;
+
+ si = xmalloc(sizeof(*si));
+ si->stage = i+1;
+ si->mode = ci->stages[i].mode;
+ oidcpy(&si->oid, &ci->stages[i].oid);
+ string_list_append(conflicted_files, path)->util = si;
+ }
+ }
+ /* string_list_sort() uses a stable sort, so we're good */
+ string_list_sort(conflicted_files);
+}
+
void merge_switch_to_result(struct merge_options *opt,
struct tree *head,
struct merge_result *result,