| 789 | } |
| 790 | |
| 791 | __attribute__((format (printf, 8, 9))) |
| 792 | static void path_msg(struct merge_options *opt, |
| 793 | enum conflict_and_info_types type, |
| 794 | int omittable_hint, /* skippable under --remerge-diff */ |
| 795 | const char *primary_path, |
| 796 | const char *other_path_1, /* may be NULL */ |
| 797 | const char *other_path_2, /* may be NULL */ |
| 798 | struct string_list *other_paths, /* may be NULL */ |
| 799 | const char *fmt, ...) |
| 800 | { |
| 801 | va_list ap; |
| 802 | struct string_list *path_conflicts; |
| 803 | struct logical_conflict_info *info; |
| 804 | struct strbuf buf = STRBUF_INIT; |
| 805 | struct strbuf *dest; |
| 806 | struct strbuf tmp = STRBUF_INIT; |
| 807 | |
| 808 | /* Sanity checks */ |
| 809 | ASSERT(omittable_hint == |
| 810 | (!starts_with(type_short_descriptions[type], "CONFLICT") && |
| 811 | !starts_with(type_short_descriptions[type], "ERROR")) || |
| 812 | type == CONFLICT_DIR_RENAME_SUGGESTED); |
| 813 | if (opt->record_conflict_msgs_as_headers && omittable_hint) |
| 814 | return; /* Do not record mere hints in headers */ |
| 815 | if (opt->priv->call_depth && opt->verbosity < 5) |
| 816 | return; /* Ignore messages from inner merges */ |
| 817 | |
| 818 | /* Ensure path_conflicts (ptr to array of logical_conflict) allocated */ |
| 819 | path_conflicts = strmap_get(&opt->priv->conflicts, primary_path); |
| 820 | if (!path_conflicts) { |
| 821 | path_conflicts = xmalloc(sizeof(*path_conflicts)); |
| 822 | string_list_init_dup(path_conflicts); |
| 823 | strmap_put(&opt->priv->conflicts, primary_path, path_conflicts); |
| 824 | } |
| 825 | |
| 826 | /* Add a logical_conflict at the end to store info from this call */ |
| 827 | info = xcalloc(1, sizeof(*info)); |
| 828 | info->type = type; |
| 829 | strvec_init(&info->paths); |
| 830 | |
| 831 | /* Handle the list of paths */ |
| 832 | strvec_push(&info->paths, primary_path); |
| 833 | if (other_path_1) |
| 834 | strvec_push(&info->paths, other_path_1); |
| 835 | if (other_path_2) |
| 836 | strvec_push(&info->paths, other_path_2); |
| 837 | if (other_paths) |
| 838 | for (int i = 0; i < other_paths->nr; i++) |
| 839 | strvec_push(&info->paths, other_paths->items[i].string); |
| 840 | |
| 841 | /* Handle message and its format, in normal case */ |
| 842 | dest = (opt->record_conflict_msgs_as_headers ? &tmp : &buf); |
| 843 | |
| 844 | va_start(ap, fmt); |
| 845 | if (opt->priv->call_depth) { |
| 846 | strbuf_addchars(dest, ' ', 2); |
| 847 | strbuf_addstr(dest, "From inner merge:"); |
| 848 | strbuf_addchars(dest, ' ', opt->priv->call_depth * 2); |
no test coverage detected