merge-ort: add a new toplevel_dir field

Due to the string-equality-iff-pointer-equality requirements placed on merged_info.directory_name, apply_directory_rename_modifications() will need to have access to the exact toplevel directory name string pointer and can't just use a new empty string. Store it in a field that we can use. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jan 19, 2021 at 19:53 UTC 05b85c6eeb1710ff83f11f71abefa2064e50e61b
1 file changed +9 -6
merge-ort.c
+9 -6
@@ -168,12 +168,15 @@ struct merge_options_internal {
168 struct rename_info renames;
169
170 /*
171 - * current_dir_name: temporary var used in collect_merge_info_callback()
171 + * current_dir_name, toplevel_dir: temporary vars
172 *
173 - * Used to set merged_info.directory_name; see documentation for that
174 - * variable and the requirements placed on that field.
173 + * These are used in collect_merge_info_callback(), and will set the
174 + * various merged_info.directory_name for the various paths we get;
175 + * see documentation for that variable and the requirements placed on
176 + * that field.
177 */
178 const char *current_dir_name;
179 + const char *toplevel_dir;
180
181 /* call_depth: recursion level counter for merging merge bases */
182 int call_depth;
@@ -682,10 +685,10 @@ static int collect_merge_info(struct merge_options *opt,
685 int ret;
686 struct tree_desc t[3];
687 struct traverse_info info;
685 - const char *toplevel_dir_placeholder = "";
688
687 - opt->priv->current_dir_name = toplevel_dir_placeholder;
688 - setup_traverse_info(&info, toplevel_dir_placeholder);
689 + opt->priv->toplevel_dir = "";
690 + opt->priv->current_dir_name = opt->priv->toplevel_dir;
691 + setup_traverse_info(&info, opt->priv->toplevel_dir);
692 info.fn = collect_merge_info_callback;
693 info.data = opt;
694 info.show_all_errors = 1;