merge-recursive: add pointer about unduly complex looking code

handle_change_delete() has a block of code displaying one of four nearly
identical messages.  Each contains about half a dozen variable
interpolations, which use nearly identical variables as well.  Someone
trying to parse this may be slowed down trying to parse the differences
and why they are here; help them out by adding a comment explaining the
differences.

Further, point out that this code structure isn't collapsed into something
more concise and readable for the programmer, because we want to keep full
messages intact in order to make translators' jobs much easier.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2018-06-09 21:16:16 -07:00 committed by Junio C Hamano
parent 8ebe7b057a
commit 5b26c3c941

View File

@ -1476,6 +1476,21 @@ static int handle_change_delete(struct merge_options *o,
if (!ret)
ret = update_file(o, 0, o_oid, o_mode, update_path);
} else {
/*
* Despite the four nearly duplicate messages and argument
* lists below and the ugliness of the nested if-statements,
* having complete messages makes the job easier for
* translators.
*
* The slight variance among the cases is due to the fact
* that:
* 1) directory/file conflicts (in effect if
* !alt_path) could cause us to need to write the
* file to a different path.
* 2) renames (in effect if !old_path) could mean that
* there are two names for the path that the user
* may know the file by.
*/
if (!alt_path) {
if (!old_path) {
output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "