On Tue, Sep 19, 2017 at 12:15 AM, Kaartic Sivaraam <kaarticsivaraam91196@xxxxxxxxx> wrote: > When trying to rename an inexistent branch to an existing branch > the rename failed specifying the new branch name exists rather than > specifying that the branch trying to be renamed doesn't exist. > > $ git branch -m tset master > fatal: A branch named 'master' already exists. > > It's conventional to report that 'tset' doesn't exist rather than > reporting that 'master' exists, the same way the 'mv' command does. > > $ git branch -m tset master This is not the 'mv' command as promised? So this is just to demonstrate the (still fictional) better error message? Maybe use a real 'mv' command here? > fatal: branch 'tset' doesn't exist. > > That has the problem that the error about an existing branch is shown > only after the user corrects the error about inexistent branch. > > $ git branch -m test master > fatal: A branch named 'master' already exists. > > This isn't useful either because the user would have corrected this error in > a single go if he had been told this alongside the first error. So, give > more useful error messages by giving errors about old branch name and new > branch name at the same time. This is possible as the branch update validation > function now returns the reason it was about to die, when requested. > > $ git branch -m tset master > fatal: branch 'tset' doesn't exist, and branch 'master' already exists > > Note: Thanks to the strbuf API that made it possible to easily construct > the composite error message strings! This shall be read as an apology to all translators out there. ;) Playing sentence lego in source code is not optimal, as other languages are very different and you cannot assume even simplest things about them (because of their variety). In this case it might not be as bad, because we're providing a whole sentence per _(translatable) unit.