Skip to content

Commit 05b85c6

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bea4336 commit 05b85c6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

merge-ort.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,15 @@ struct merge_options_internal {
168168
struct rename_info renames;
169169

170170
/*
171-
* current_dir_name: temporary var used in collect_merge_info_callback()
171+
* current_dir_name, toplevel_dir: temporary vars
172172
*
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.
175177
*/
176178
const char *current_dir_name;
179+
const char *toplevel_dir;
177180

178181
/* call_depth: recursion level counter for merging merge bases */
179182
int call_depth;
@@ -682,10 +685,10 @@ static int collect_merge_info(struct merge_options *opt,
682685
int ret;
683686
struct tree_desc t[3];
684687
struct traverse_info info;
685-
const char *toplevel_dir_placeholder = "";
686688

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);
689692
info.fn = collect_merge_info_callback;
690693
info.data = opt;
691694
info.show_all_errors = 1;

0 commit comments

Comments
 (0)