|
18 | 18 | #include "merge-ort.h"
|
19 | 19 |
|
20 | 20 | #include "alloc.h"
|
| 21 | +#include "attr.h" |
21 | 22 | #include "blob.h"
|
22 | 23 | #include "cache-tree.h"
|
23 | 24 | #include "commit.h"
|
@@ -220,6 +221,16 @@ struct merge_options_internal {
|
220 | 221 | */
|
221 | 222 | struct rename_info renames;
|
222 | 223 |
|
| 224 | + /* |
| 225 | + * attr_index: hacky minimal index used for renormalization |
| 226 | + * |
| 227 | + * renormalization code _requires_ an index, though it only needs to |
| 228 | + * find a .gitattributes file within the index. So, when |
| 229 | + * renormalization is important, we create a special index with just |
| 230 | + * that one file. |
| 231 | + */ |
| 232 | + struct index_state attr_index; |
| 233 | + |
223 | 234 | /*
|
224 | 235 | * current_dir_name, toplevel_dir: temporary vars
|
225 | 236 | *
|
@@ -399,6 +410,9 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
|
399 | 410 | string_list_clear(&opti->paths_to_free, 0);
|
400 | 411 | opti->paths_to_free.strdup_strings = 0;
|
401 | 412 |
|
| 413 | + if (opti->attr_index.cache_nr) |
| 414 | + discard_index(&opti->attr_index); |
| 415 | + |
402 | 416 | /* Free memory used by various renames maps */
|
403 | 417 | for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
|
404 | 418 | strintmap_func(&renames->dirs_removed[i]);
|
@@ -3407,6 +3421,8 @@ void merge_finalize(struct merge_options *opt,
|
3407 | 3421 | {
|
3408 | 3422 | struct merge_options_internal *opti = result->priv;
|
3409 | 3423 |
|
| 3424 | + if (opt->renormalize) |
| 3425 | + git_attr_set_direction(GIT_ATTR_CHECKIN); |
3410 | 3426 | assert(opt->priv == NULL);
|
3411 | 3427 |
|
3412 | 3428 | clear_or_reinit_internal_opts(opti, 0);
|
@@ -3482,6 +3498,10 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
|
3482 | 3498 | /* Default to histogram diff. Actually, just hardcode it...for now. */
|
3483 | 3499 | opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
|
3484 | 3500 |
|
| 3501 | + /* Handle attr direction stuff for renormalization */ |
| 3502 | + if (opt->renormalize) |
| 3503 | + git_attr_set_direction(GIT_ATTR_CHECKOUT); |
| 3504 | + |
3485 | 3505 | /* Initialization of opt->priv, our internal merge data */
|
3486 | 3506 | trace2_region_enter("merge", "allocate/init", opt->repo);
|
3487 | 3507 | if (opt->priv) {
|
|
0 commit comments