Skip to content

Commit beb0614

Browse files
newrengitster
authored andcommitted
merge-ort: add data structures for an alternate tree traversal
In order to determine whether directory rename detection is needed, we as a pre-requisite need a way to traverse through all the files in a given tree before visiting any directories within that tree. traverse_trees() only iterates through the entries in the order they appear, so add some data structures that will store all the entries as we iterate through them in traverse_trees(), which will allow us to re-traverse them in our desired order. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 32a56df commit beb0614

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

merge-ort.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ enum merge_side {
5151
MERGE_SIDE2 = 2
5252
};
5353

54+
struct traversal_callback_data {
55+
unsigned long mask;
56+
unsigned long dirmask;
57+
struct name_entry names[3];
58+
};
59+
5460
struct rename_info {
5561
/*
5662
* All variables that are arrays of size 3 correspond to data tracked
@@ -102,6 +108,22 @@ struct rename_info {
102108
*/
103109
struct strset relevant_sources[3];
104110

111+
/*
112+
* callback_data_*: supporting data structures for alternate traversal
113+
*
114+
* We sometimes need to be able to traverse through all the files
115+
* in a given tree before all immediate subdirectories within that
116+
* tree. Since traverse_trees() doesn't do that naturally, we have
117+
* a traverse_trees_wrapper() that stores any immediate
118+
* subdirectories while traversing files, then traverses the
119+
* immediate subdirectories later. These callback_data* variables
120+
* store the information for the subdirectories so that we can do
121+
* that traversal order.
122+
*/
123+
struct traversal_callback_data *callback_data;
124+
int callback_data_nr, callback_data_alloc;
125+
char *callback_data_traverse_path;
126+
105127
/*
106128
* needed_limit: value needed for inexact rename detection to run
107129
*
@@ -396,6 +418,10 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
396418
}
397419
strmap_clear(&opti->output, 0);
398420
}
421+
422+
/* Clean out callback_data as well. */
423+
FREE_AND_NULL(renames->callback_data);
424+
renames->callback_data_nr = renames->callback_data_alloc = 0;
399425
}
400426

401427
static int err(struct merge_options *opt, const char *err, ...)

0 commit comments

Comments
 (0)