public bool TryCreateBranch()
        {
            Verify.State.IsTrue(View != null, "Controller is not attached to a view.");

            var branchName = View.BranchName.Value.Trim();

            if (!GitControllerUtility.ValidateNewBranchName(branchName, StashedState.Repository, View.BranchName, View.ErrorNotifier))
            {
                return(false);
            }

            try
            {
                using (View.ChangeCursor(MouseCursor.WaitCursor))
                {
                    StashedState.ToBranch(branchName);
                }
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    View as IWin32Window,
                    exc.Message,
                    string.Format(Resources.ErrFailedToCreateBranch, branchName),
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
        public bool TryRename()
        {
            Verify.State.IsTrue(View != null, "Controller is not attached to a view.");

            var repository = Branch.Repository;
            var oldName    = Branch.Name;
            var newName    = View.NewName.Value.Trim();

            if (oldName == newName)
            {
                return(true);
            }
            if (!GitControllerUtility.ValidateNewBranchName(newName, repository, View.NewName, View.ErrorNotifier))
            {
                return(false);
            }

            try
            {
                using (View.ChangeCursor(MouseCursor.WaitCursor))
                {
                    Branch.Name = newName;
                }
            }
            catch (BranchAlreadyExistsException)
            {
                View.ErrorNotifier.NotifyError(View.NewName,
                                               new UserInputError(
                                                   Resources.ErrInvalidBranchName,
                                                   Resources.ErrBranchAlreadyExists));
                return(false);
            }
            catch (InvalidBranchNameException exc)
            {
                View.ErrorNotifier.NotifyError(View.NewName,
                                               new UserInputError(
                                                   Resources.ErrInvalidBranchName,
                                                   exc.Message));
                return(false);
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    View as IWin32Window,
                    exc.Message,
                    string.Format(Resources.ErrFailedToRenameBranch, oldName),
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }