merge-recursive: distinguish "removed" and "overwritten" messages

To limit the number of possible error messages, the error messages for
the case would_lose_untracked_file and would_lose_orphaned in
unpack_trees_options.msgs were handled with a single string,
parameterized by an action string ("overwritten" or "removed").

Instead, we consider them as two different cases, with unparameterized
string. This will make it easier to make separate lists sorted by error
types later.

Only the bind_overlap case still takes two %s parameters, but that's
unavoidable.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matthieu Moy
2010-08-11 10:38:06 +02:00
committed by Junio C Hamano
parent 23cbf11b5c
commit 08402b0409
3 changed files with 51 additions and 32 deletions

View File

@ -1197,13 +1197,16 @@ void set_porcelain_error_msgs(const char **msgs, const char *cmd)
"Updating '%s' would lose untracked files in it. Aborting.";
if (advice_commit_before_merge)
msg = "Untracked working tree file '%%s' would be %%s by %s. Aborting"
msg = "Untracked working tree file '%%s' would be %s by %s. Aborting"
"Please move or remove them before you can %s.";
else
msg = "Untracked working tree file '%%s' would be %%s by %s. Aborting";
tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen(cmd2) - 3);
sprintf(tmp, msg, cmd, cmd2);
msgs[ERROR_WOULD_LOSE_UNTRACKED] = tmp;
msg = "Untracked working tree file '%%s' would be %s by %s. Aborting";
tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen("removed") + strlen(cmd2) - 4);
sprintf(tmp, msg, "removed", cmd, cmd2);
msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = tmp;
tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen("overwritten") + strlen(cmd2) - 4);
sprintf(tmp, msg, "overwritten", cmd, cmd2);
msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = tmp;
}
int merge_trees(struct merge_options *o,