Fix crash happening when deleting a remote branch. Closes #2538.