Kaartic Sivaraam <kaartic.sivaraam@xxxxxxxxx> writes: > +static void get_error_msg(struct strbuf* error_msg, > + const char* oldname, enum old_branch_validation_result old_branch_name_res, > + const char* newname, enum branch_validation_result new_branch_name_res) > +{ > + const char* connector_string = "; "; > + unsigned append_connector = 0; > + > + switch (old_branch_name_res) { > + case VALIDATION_1_FATAL_INVALID_OLD_BRANCH_NAME: > + strbuf_addf(error_msg, > + _("old branch name '%s' is invalid"), oldname); > + append_connector = 1; > + break; > + case VALIDATION_1_FATAL_OLD_BRANCH_DOESNT_EXIST: > + strbuf_addf(error_msg, > + _("branch '%s' doesn't exist"), oldname); > + append_connector = 1; > + break; > + > + /* not necessary to handle nonfatal cases */ > + case VALIDATION_1_PASS_OLD_BRANCH_EXISTS: > + case VALIDATION_1_WARN_BAD_OLD_BRANCH_NAME: > + break; > + } > + > + switch (new_branch_name_res) { > + case VALIDATION_FATAL_BRANCH_EXISTS_NO_FORCE: > + strbuf_addf(error_msg, "%s", > + (append_connector) ? connector_string : ""); > + strbuf_addf(error_msg, > + _("branch '%s' already exists"), newname); > + break; > + case VALIDATION_FATAL_CANNOT_FORCE_UPDATE_CURRENT_BRANCH: > + strbuf_addf(error_msg, "%s", > + (append_connector) ? connector_string : ""); > + strbuf_addstr(error_msg, > + _("cannot force update the current branch")); > + break; > + case VALIDATION_FATAL_INVALID_BRANCH_NAME: > + strbuf_addf(error_msg, "%s", > + (append_connector) ? connector_string : ""); > + strbuf_addf(error_msg, > + _("new branch name '%s' is invalid"), newname); > + break; > + > + /* not necessary to handle nonfatal cases */ > + case VALIDATION_PASS_BRANCH_DOESNT_EXIST: > + case VALIDATION_PASS_BRANCH_EXISTS: > + case VALIDATION_WARN_BRANCH_EXISTS: > + break; > + } > +} Quite honestly, I am not sure if this amount of new code that results in sentence lego is really worth it. Is it so wrong for "branch -m tset master" to complain that master already exists so no branch can be renamed to it?