Re: [PATCH v2 12/13] merge-tree: add a --allow-unrelated-histories flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 2, 2022, 21:32 UTC
- Message-ID
- <xmqqleytvtrz.fsf@gitster.g>
- In-Reply-To
- <25677d5038cab591774eaa1349365871b23aa2fc.1643479633.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> @@ -430,7 +431,7 @@ static int real_merge(struct merge_tree_options *o,
> * merge_incore_recursive in merge-ort.h
> */
> common = get_merge_bases(parent1, parent2);
> - if (!common)
> + if (!common && !o->allow_unrelated_histories)
> die(_("refusing to merge unrelated histories"));
> for (j = common; j; j = j->next)
> commit_list_insert(j->item, &merge_bases);Curious. This step _adds_ an "--allow" option from the command line, but we actually did not have to die() when seeing that there is no common ancestor before this step. The end result is OK either way.
Show 10 quoted lines
> @@ -494,6 +495,10 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
> &o.exclude_modes_oids_stages,
> N_("list conflicted files without modes/oids/stages"),
> PARSE_OPT_NONEG),
> + OPT_BOOL_F(0, "allow-unrelated-histories",
> + &o.allow_unrelated_histories,
> + N_("allow merging unrelated histories"),
> + PARSE_OPT_NONEG),
> OPT_END()
> };