[PATCH v3 2/4] merge: clarify call chain
- From
Michael J Gruber <git@grubix.eu>
- Date
- Aug 23, 2017, 12:10 UTC
- Message-ID
- <28682d03456d49b10b91c0c63de0f4119bcae7cf.1503489842.git.git@grubix.eu>
- In-Reply-To
- <xmqq1so34m6d.fsf@gitster.mtv.corp.google.com>
prepare_to_commit() cannot be reached in the non-squash case: It is called by merge_trivial() and finish_automerge() only, but the calls to the latter are somewhat hard to track:
If option_commit is not set, the code in cmd_merge() uses a fake conflict return code (ret=1) to avoid writing the tree, which also avoids setting automerge_was_ok (just as in the proper ret==1 case), so that finish_automerge() is not called.
To ensure that no code change breaks that assumption, safe-guard prepare_to_commit() by a BUG() statement.
Suggested-by: junio Signed-off-by: Michael J Gruber <git@grubix.eu> --- builtin/merge.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/builtin/merge.c b/builtin/merge.c index cc57052993..dafec80fa9 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -763,6 +763,8 @@ static void prepare_to_commit(struct commit_list *remoteheads) struct strbuf msg = STRBUF_INIT; strbuf_addbuf(&msg, &merge_msg); strbuf_addch(&msg, '\n'); + if (squash) + BUG("the control must not reach here under --squash"); if (0 < option_edit) strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char); if (signoff)
-- 2.14.1.426.g4352aa77a5