From: Kaartic Sivaraam Date: Tue, 19 Sep 2017 08:41:29 GMT Subject: [RFC SAMPLE] builtin/branch: give more useful error messages when renaming Message-ID: In-Reply-To: <20170919071525.9404-6-kaarticsivaraam91196@gmail.com> The patch series results in a change in output as specified below. Only few cases have been shown here to keep it short. The output for other cases are similar. $ git branch * master foo bar Before patch, $ # Trying to rename non-existent branch $ git branch -m hypothet no_such_branch error: refname refs/heads/hypothet not found fatal: Branch rename failed $ # Trying to rename non-existent branch into existing one $ git branch -m hypothet master error: refname refs/heads/hypothet not found fatal: Branch rename failed $ # Trying to force update current branch $ git branch -M foo master fatal: Cannot force update the current branch. $ # Trying to force rename an in-existent branch with an invalid name $ git branch -M hypothet ?123 fatal: '?123' is not a valid branch name. After patch, $ # Trying to rename non-existent branch $ git branch -m hypothet no_such_branch fatal: branch 'hypothet' doesn't exist $ # Trying to rename non-existent branch into existing one $ git branch -m hypothet master fatal: branch 'hypothet' doesn't exist, and branch 'master' already exists $ # Trying to force update current branch $ git branch -M foo master fatal: cannot force update the current branch $ # Trying to force rename an in-existent branch with an invalid name $ git branch -M hypothet ?123 fatal: branch 'hypothet' doesn't exist, and branch name '?123' is invalid