示例#1
0
        private FormProcess CreateFormProcess(string source, string curLocalBranch, string curRemoteBranch)
        {
            if (Fetch.Checked)
            {
                return(new FormRemoteProcess(Module, Module.FetchCmd(source, curRemoteBranch, curLocalBranch, GetTagsArg(), Unshallow.Checked, Prune.Checked)));
            }

            Debug.Assert(Merge.Checked || Rebase.Checked, "Merge.Checked || Rebase.Checked");

            return(new FormRemoteProcess(Module, Module.PullCmd(source, curRemoteBranch, Rebase.Checked, GetTagsArg(), Unshallow.Checked, Prune.Checked))
            {
                HandleOnExitCallback = HandlePullOnExit
            });

            bool?GetTagsArg()
            {
                return(AllTags.Checked ? true : NoTags.Checked?false : (bool?)null);
            }

            bool HandlePullOnExit(ref bool isError, FormProcess form)
            {
                if (!isError)
                {
                    return(false);
                }

                if (!PullFromRemote.Checked || string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
                {
                    return(false);
                }

                // auto pull only if current branch was rejected
                var isRefRemoved = new Regex(@"Your configuration specifies to .* the ref '.*'[\r]?\nfrom the remote, but no such ref was fetched.");

                if (isRefRemoved.IsMatch(form.GetOutputString()))
                {
                    int idx = PSTaskDialog.cTaskDialog.ShowCommandBox(form,
                                                                      _pruneBranchesCaption.Text,
                                                                      _pruneBranchesMainInstruction.Text,
                                                                      _pruneBranchesBranch.Text,
                                                                      _pruneBranchesButtons.Text,
                                                                      true);
                    if (idx == 0)
                    {
                        string remote   = _NO_TRANSLATE_Remotes.Text;
                        string pruneCmd = "remote prune " + remote;
                        using (var formPrune = new FormRemoteProcess(Module, pruneCmd)
                        {
                            Remote = remote,
                            Text = string.Format(_pruneFromCaption.Text, remote)
                        })
                        {
                            formPrune.ShowDialog(form);
                        }
                    }
                }

                return(false);
            }
        }
 /// <summary>
 /// Re-applies the current options/rules to the WC.
 /// </summary>
 public void RefreshWorkingCopy()
 {
     // Re-apply tree to the index
     // TODO: check how it affects the uncommitted working copy changes
     using (var fromProcess = new FormRemoteProcess(_gitcommands.Module, AppSettings.GitCommand, RefreshWorkingCopyCommandName))
         fromProcess.ShowDialog(Form.ActiveForm);
 }
示例#3
0
 private void PruneClick(object sender, EventArgs e)
 {
     if (_selectedRemote == null)
     {
         return;
     }
     FormRemoteProcess.ShowDialog(this, "remote prune " + _selectedRemote.Name);
 }
示例#4
0
            public void Fetch()
            {
                var cmd = Module.FetchCmd(FullPath, null, null, null);

                if (FormRemoteProcess.ShowDialog(TreeViewNode.TreeView, Module, cmd))
                {
                    UICommands.RepoChangedNotifier.Notify();
                }
            }
示例#5
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Default;
                _branchListLoader.Cancel();

                var dirTo = _NO_TRANSLATE_To.Text;
                if (!dirTo.EndsWith(AppSettings.PathSeparator.ToString()) && !dirTo.EndsWith(AppSettings.PathSeparatorWrong.ToString()))
                {
                    dirTo += AppSettings.PathSeparator.ToString();
                }

                dirTo += _NO_TRANSLATE_NewDirectory.Text;

                Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text);
                Repositories.AddMostRecentRepository(dirTo);

                if (!Directory.Exists(dirTo))
                {
                    Directory.CreateDirectory(dirTo);
                }

                var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                                                          CentralRepository.Checked, cbIntializeAllSubmodules.Checked, Branches.Text, null);
                using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd))
                {
                    fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                    fromProcess.ShowDialog(this);

                    if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch())
                    {
                        return;
                    }
                }

                if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Hide();
                    GitUICommands uiCommands = new GitUICommands(dirTo);
                    uiCommands.StartBrowseDialog();
                }
                else if (ShowInTaskbar == false && GitModuleChanged != null &&
                         AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    GitModuleChanged(new GitModule(dirTo));
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
        private void SaveClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(RemoteName.Text))
            {
                return;
            }

            try
            {
                // disable the control while saving
                tabControl1.Enabled = false;

                if ((string.IsNullOrEmpty(comboBoxPushUrl.Text) && checkBoxSepPushUrl.Checked) ||
                    (comboBoxPushUrl.Text.Equals(Url.Text, StringComparison.OrdinalIgnoreCase)))
                {
                    checkBoxSepPushUrl.Checked = false;
                }

                // update all other remote properties
                var result = _gitRemoteController.SaveRemote(_selectedRemote,
                                                             RemoteName.Text,
                                                             Url.Text,
                                                             checkBoxSepPushUrl.Checked ? comboBoxPushUrl.Text : null,
                                                             PuttySshKey.Text);
                if (OnRemoteRenamedOrAdded != null)
                {
                    OnRemoteRenamedOrAdded(
                        _selectedRemote != null? _selectedRemote.Name : RemoteName.Text, RemoteName.Text);
                }

                if (!string.IsNullOrEmpty(result.UserMessage))
                {
                    MessageBox.Show(this, result.UserMessage, _gitMessage.Text);
                }

                // if the user has just created a fresh new remote
                // there may be a need to configure it
                if (result.ShouldUpdateRemote && !string.IsNullOrEmpty(Url.Text) &&
                    DialogResult.Yes == MessageBox.Show(this,
                                                        _questionAutoPullBehaviour.Text,
                                                        _questionAutoPullBehaviourCaption.Text,
                                                        MessageBoxButtons.YesNo))
                {
                    FormRemoteProcess.ShowDialog(this, "remote update");
                    _gitRemoteController.ConfigureRemotes(RemoteName.Text);
                    UICommands.RepoChangedNotifier.Notify();
                }
            }
            finally
            {
                // re-enable the control and re-initialize
                tabControl1.Enabled = true;
                Initialize(RemoteName.Text);
            }
        }
示例#7
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (!DeleteRemote.Checked)
                {
                    return;
                }

                List <IGitRef> selectedBranches = Branches.GetSelectedBranches().ToList();

                var hasUnmergedBranches = selectedBranches.Any(branch => !_mergedBranches.Contains(branch.CompleteName));

                if (hasUnmergedBranches)
                {
                    if (MessageBox.Show(this, _confirmDeleteUnmergedRemoteBranchMessage.Text, _deleteRemoteBranchesCaption.Text, MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                foreach (var remoteGroup in selectedBranches.GroupBy(b => b.Remote))
                {
                    string remote = remoteGroup.Key;

                    EnsurePageant(remote);

                    var cmd = new GitDeleteRemoteBranchesCmd(remote, remoteGroup);

                    ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

                    using (var form = new FormRemoteProcess(Module, cmd.ToLine())
                    {
                        Remote = remote
                    })
                    {
                        form.ShowDialog();

                        if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                        {
                            ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                        }
                    }
                }

                UICommands.RepoChangedNotifier.Notify();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

            Close();
        }
示例#8
0
            public void Fetch()
            {
                var remoteBranchInfo = GetRemoteBranchInfo();
                var cmd = Module.FetchCmd(remoteBranchInfo.Remote, remoteBranchInfo.BranchName,
                                          null, null);
                var ret = FormRemoteProcess.ShowDialog(TreeViewNode.TreeView, Module, cmd);

                if (ret)
                {
                    UICommands.RepoChangedNotifier.Notify();
                }
            }
示例#9
0
        private void RemoveRemoteTag(string tagName)
        {
            var pushCmd = string.Format("push \"{0}\" :refs/tags/{1}", remotesComboboxControl1.SelectedRemote, tagName);

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            using var form = new FormRemoteProcess(UICommands, process: null, pushCmd);
            ////Remote = currentRemote,
            ////Text = string.Format(_deleteFromCaption.Text, currentRemote),
            form.ShowDialog();

            if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
            {
                ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
            }
        }
示例#10
0
        private void LoadMultiBranchViewData(string remote)
        {
            Cursor = Cursors.AppStarting;
            try
            {
                IList <IGitRef> remoteHeads;
                if (Module.EffectiveSettings.Detailed.GetRemoteBranchesDirectlyFromRemote.ValueOrDefault)
                {
                    EnsurePageant(remote);
                    var cmdGetBranchesFromRemote = "ls-remote --heads \"" + remote + "\"";
                    using (var formProcess = new FormRemoteProcess(Module, cmdGetBranchesFromRemote)
                    {
                        Remote = remote
                    })
                    {
                        formProcess.ShowDialog(this);
                        if (formProcess.ErrorOccurred())
                        {
                            return;
                        }

                        var processOutput = formProcess.GetOutputString();
                        var cmdOutput     = TakeCommandOutput(processOutput);
                        remoteHeads = Module.GetTreeRefs(cmdOutput);
                        if (remoteHeads == null)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    // use remote branches from the git's local database if there were problems with receiving branches from the remote server
                    remoteHeads = Module.GetRemoteBranches().Where(r => r.Remote == remote).ToList();
                }

                ProcessHeads(remote, remoteHeads);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
示例#11
0
        private void PushTag(string tagName)
        {
            var pushCmd = GitCommandHelpers.PushTagCmd(_currentRemote, tagName, false);

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                Remote = _currentRemote,
                Text = string.Format(_pushToCaption.Text, _currentRemote),
            })
            {
                form.ShowDialog();

                if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                }
            }
        }
示例#12
0
        private void RemoveRemoteTag(string tagName)
        {
            var pushCmd = string.Format("push \"{0}\" :refs/tags/{1}", remotesComboboxControl1.SelectedRemote, tagName);

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            using (var form = new FormRemoteProcess(Module, pushCmd)
                                    {
                                        ////Remote = currentRemote,
                                        ////Text = string.Format(_deleteFromCaption.Text, currentRemote),
                                    })
            {
                form.ShowDialog();

                if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                }
            }
        }
示例#13
0
        private void Clone(IHostedRepository repo)
        {
            string targetDir = GetTargetDir();

            if (targetDir == null)
            {
                return;
            }

            string repoSrc = repo.CloneReadWriteUrl;

            string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir);

            FormRemoteProcess formRemoteProcess = new FormRemoteProcess(new GitModule(null), AppSettings.GitCommand, cmd);

            formRemoteProcess.Remote = repoSrc;
            formRemoteProcess.ShowDialog();

            if (formRemoteProcess.ErrorOccurred())
            {
                return;
            }

            GitModule module = new GitModule(targetDir);

            if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl))
            {
                var error = module.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl);
                if (!string.IsNullOrEmpty(error))
                {
                    MessageBox.Show(this, error, _strCouldNotAddRemote.Text);
                }
            }

            if (GitModuleChanged != null)
            {
                GitModuleChanged(this, new GitModuleEventArgs(module));
            }

            Close();
        }
示例#14
0
        private void RemoveRemoteTag(string tagName)
        {
            var pushCmd = string.Format("push \"{0}\" :refs/tags/{1}", remotesComboboxControl1.SelectedRemote, tagName);

            ScriptManager.RunEventScripts(Module, ScriptEvent.BeforePush);

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                ////Remote = currentRemote,
                ////Text = string.Format(_deleteFromCaption.Text, currentRemote),
            })
            {
                form.ShowDialog();

                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPush);
                }
            }
        }
示例#15
0
        private void PushTag(string tagName)
        {
            var currentBranchRemote = Settings.Module.GetSetting(string.Format("branch.{0}.remote", Settings.Module.GetSelectedBranch()));
            var pushCmd             = GitCommandHelpers.PushTagCmd(currentBranchRemote, tagName, false);

            ScriptManager.RunEventScripts(ScriptEvent.BeforePush);

            var form = new FormRemoteProcess(pushCmd)
            {
                Remote = currentBranchRemote,
                Text   = string.Format(_pushToCaption.Text, currentBranchRemote),
            };

            form.ShowDialog();

            if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                !Settings.Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
            {
                ScriptManager.RunEventScripts(ScriptEvent.AfterPush);
            }
        }
        private void Clone(IHostedRepository repo)
        {
            string targetDir = GetTargetDir();

            if (targetDir == null)
            {
                return;
            }

            string repoSrc = repo.CloneReadWriteUrl;

            var cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir, depth: GetDepth());

            var formRemoteProcess = new FormRemoteProcess(new GitModule(null), AppSettings.GitCommand, cmd)
            {
                Remote = repoSrc
            };

            formRemoteProcess.ShowDialog();

            if (formRemoteProcess.ErrorOccurred())
            {
                return;
            }

            var module = new GitModule(targetDir);

            if (addUpstreamRemoteAsCB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl))
            {
                var error = module.AddRemote(addUpstreamRemoteAsCB.Text.Trim(), repo.ParentReadOnlyUrl);
                if (!string.IsNullOrEmpty(error))
                {
                    MessageBox.Show(this, error, _strCouldNotAddRemote.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            _gitModuleChanged?.Invoke(this, new GitModuleEventArgs(module));

            Close();
        }
示例#17
0
        private bool HandlePullOnExit(ref bool isError, FormProcess form)
        {
            if (!isError)
            {
                return(false);
            }

            if (!PullFromRemote.Checked || string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
            {
                return(false);
            }

            //auto pull only if current branch was rejected
            Regex isRefRemoved = new Regex(@"Your configuration specifies to .* the ref '.*'[\r]?\nfrom the remote, but no such ref was fetched.");

            if (isRefRemoved.IsMatch(form.GetOutputString()))
            {
                int idx = PSTaskDialog.cTaskDialog.ShowCommandBox(form,
                                                                  _pruneBranchesCaption.Text,
                                                                  _pruneBranchesMainInstruction.Text,
                                                                  _pruneBranchesBranch.Text,
                                                                  _pruneBranchesButtons.Text,
                                                                  true);
                if (idx == 0)
                {
                    string remote   = _NO_TRANSLATE_Remotes.Text;
                    string pruneCmd = "remote prune " + remote;
                    using (var formPrune = new FormRemoteProcess(Module, pruneCmd)
                    {
                        Remote = remote,
                        Text = string.Format(_pruneFromCaption.Text, remote)
                    })
                    {
                        formPrune.ShowDialog(form);
                    }
                }
            }

            return(false);
        }
示例#18
0
        private void RemoveRemoteTag(string tagName)
        {
            var pushCmd = string.Format("push \"{0}\" :refs/tags/{1}", currentRemote, tagName);

            ScriptManager.RunEventScripts(Module, ScriptEvent.BeforePush);

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                Remote = currentRemote,
                Text = string.Format(_deleteFromCaption.Text, currentRemote),
            })

            {
                form.ShowDialog();

                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPush);
                }
            }
        }
示例#19
0
        private void LoadMultiBranchViewData(string remote, IEnumerable<GitRef> localHeads)
        {
            Cursor = Cursors.AppStarting;
            try
            {
                IEnumerable<GitRef> remoteHeads = null;
                if (Module.EffectiveSettings.Detailed.GetRemoteBranchesDirectlyFromRemote.ValueOrDefault)
                {
                    EnsurePageant(remote);
                    var cmdGetBranchesFromRemote = "ls-remote --heads \"" + remote + "\"";
                    using (var formProcess = new FormRemoteProcess(Module, cmdGetBranchesFromRemote)
                    {
                        Remote = remote
                    })
                    {

                        formProcess.ShowDialog(this);
                        if (formProcess.ErrorOccurred())
                        {
                            return;
                        }
                        var processOutput = formProcess.GetOutputString();
                        var cmdOutput = TakeCommandOutput(processOutput);
                        remoteHeads = Module.GetTreeRefs(cmdOutput);
                        if (remoteHeads == null)
                            return;
                    }
                }
                else
                {
                    //use remote branches from the git's local database if there were problems with receiving branches from the remote server
                    remoteHeads = Module.GetRemoteBranches().Where(r => r.Remote == remote);
                }
                ProcessHeads(remote, localHeads, remoteHeads);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
示例#20
0
        private void PushTag(string tagName)
        {
            var currentBranchRemote = Settings.Module.GetSetting(string.Format("branch.{0}.remote", Settings.Module.GetSelectedBranch()));
            var pushCmd = GitCommandHelpers.PushTagCmd(currentBranchRemote, tagName, false);

            ScriptManager.RunEventScripts(ScriptEvent.BeforePush);

            var form = new FormRemoteProcess(pushCmd)
            {
                Remote = currentBranchRemote,
                Text = string.Format(_pushToCaption.Text, currentBranchRemote),
            };

            form.ShowDialog();

            if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                !Settings.Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
            {
                ScriptManager.RunEventScripts(ScriptEvent.AfterPush);
            }
        }
示例#21
0
        private void SaveClick(object sender, EventArgs e)
        {
            var output = "";

            if ((string.IsNullOrEmpty(comboBoxPushUrl.Text) && checkBoxSepPushUrl.Checked) ||
                (comboBoxPushUrl.Text == Url.Text))
            {
                checkBoxSepPushUrl.Checked = false;
            }

            if (string.IsNullOrEmpty(_remote))
            {
                if (string.IsNullOrEmpty(RemoteName.Text) && string.IsNullOrEmpty(Url.Text))
                {
                    return;
                }

                output = Module.AddRemote(RemoteName.Text, Url.Text);

                if (checkBoxSepPushUrl.Checked)
                {
                    Module.SetPathSetting(string.Format(SettingKeyString.RemotePushUrl, RemoteName.Text), comboBoxPushUrl.Text);
                }

                if (MessageBox.Show(this, _questionAutoPullBehaviour.Text, _questionAutoPullBehaviourCaption.Text,
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var remoteUrl = Url.Text;

                    if (!string.IsNullOrEmpty(remoteUrl))
                    {
                        FormRemoteProcess.ShowDialog(this, "remote update");
                        ConfigureRemotes();
                    }
                    else
                    {
                        MessageBox.Show(this, _warningValidRemote.Text, _warningValidRemoteCaption.Text);
                    }
                }
            }
            else
            {
                if (RemoteName.Text != _remote)
                {
                    output = Module.RenameRemote(_remote, RemoteName.Text);
                }

                Module.SetPathSetting(string.Format(SettingKeyString.RemoteUrl, RemoteName.Text), Url.Text);
                Module.SetPathSetting(string.Format("remote.{0}.puttykeyfile", RemoteName.Text), PuttySshKey.Text);
                if (checkBoxSepPushUrl.Checked)
                {
                    Module.SetPathSetting(string.Format(SettingKeyString.RemotePushUrl, RemoteName.Text), comboBoxPushUrl.Text);
                }
                else
                {
                    Module.UnsetSetting(string.Format(SettingKeyString.RemotePushUrl, RemoteName.Text));
                }
            }

            if (!string.IsNullOrEmpty(output))
            {
                MessageBox.Show(this, output, _hintDelete.Text);
            }

            Initialize();
        }
示例#22
0
        private bool PushChanges(IWin32Window owner)
        {
            ErrorOccurred = false;
            if (PushToUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
            {
                MessageBox.Show(owner, _selectDestinationDirectory.Text);
                return false;
            }
            if (PushToRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
            {
                MessageBox.Show(owner, _selectRemote.Text);
                return false;
            }
            if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text))
            {
                MessageBox.Show(owner, _selectTag.Text);
                return false;
            }

            //Extra check if the branch is already known to the remote, give a warning when not.
            //This is not possible when the remote is an URL, but this is ok since most users push to
            //known remotes anyway.
            if (TabControlTagBranch.SelectedTab == BranchTab && PushToRemote.Checked &&
                !Module.IsBareRepository())
            {
                //If the current branch is not the default push, and not known by the remote
                //(as far as we know since we are disconnected....)
                if (_NO_TRANSLATE_Branch.Text != AllRefs &&
                    RemoteBranch.Text != GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text) &&
                    !Module.GetRefs(true, true).Any(x => x.Remote == _NO_TRANSLATE_Remotes.Text && x.LocalName == RemoteBranch.Text))
                {
                    //Ask if this is really what the user wants
                    if (!AppSettings.DontConfirmPushNewBranch &&
                        MessageBox.Show(owner, _branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) ==
                            DialogResult.No)
                    {
                        return false;
                    }
                }
            }

            if (PushToUrl.Checked)
                Repositories.AddMostRecentRepository(PushDestination.Text);
            AppSettings.RecursiveSubmodules = RecursiveSubmodules.SelectedIndex;

            var remote = "";
            string destination;
            if (PushToUrl.Checked)
            {
                destination = PushDestination.Text;
            }
            else
            {
                if (GitCommandHelpers.Plink())
                {
                    if (!File.Exists(AppSettings.Pageant))
                        MessageBoxes.PAgentNotFound(owner);
                    else
                        Module.StartPageantForRemote(_NO_TRANSLATE_Remotes.Text);
                }

                destination = _NO_TRANSLATE_Remotes.Text;
                remote = _NO_TRANSLATE_Remotes.Text.Trim();
            }

            string pushCmd;
            if (TabControlTagBranch.SelectedTab == BranchTab)
            {
                bool track = ReplaceTrackingReference.Checked;
                if (!track && !string.IsNullOrWhiteSpace(RemoteBranch.Text))
                {
                    GitRef selectedLocalBranch = _NO_TRANSLATE_Branch.SelectedItem as GitRef;
                    track = selectedLocalBranch != null && string.IsNullOrEmpty(selectedLocalBranch.TrackingRemote);

                    string[] remotes = _NO_TRANSLATE_Remotes.DataSource as string[];
                    if (remotes != null)
                        foreach (string remoteBranch in remotes)
                            if (!string.IsNullOrEmpty(remoteBranch) && _NO_TRANSLATE_Branch.Text.StartsWith(remoteBranch))
                                track = false;

                    if (track && !AppSettings.DontConfirmAddTrackingRef)
                    {
                        DialogResult result = MessageBox.Show(String.Format(_updateTrackingReference.Text, selectedLocalBranch.Name, RemoteBranch.Text), _pushCaption.Text, MessageBoxButtons.YesNoCancel);

                        if (result == DialogResult.Cancel)
                            return false;

                        track = result == DialogResult.Yes;
                    }
                }

                // Try to make source rev into a fully qualified branch name. If that
                // doesn't exist, then it must be something other than a branch, so
                // fall back to using the name just as it was passed in.
                string srcRev = "";
                bool pushAllBranches = false;
                if (_NO_TRANSLATE_Branch.Text == AllRefs)
                    pushAllBranches = true;
                else
                {
                    srcRev = GitCommandHelpers.GetFullBranchName(_NO_TRANSLATE_Branch.Text);
                    if (String.IsNullOrEmpty(Module.RevParse(srcRev)))
                        srcRev = _NO_TRANSLATE_Branch.Text;
                }

                pushCmd = GitCommandHelpers.PushCmd(destination, srcRev, RemoteBranch.Text,
                    pushAllBranches, ForcePushBranches.Checked, track, RecursiveSubmodules.SelectedIndex);
            }
            else if (TabControlTagBranch.SelectedTab == TagTab)
            {
                string tag = TagComboBox.Text;
                bool pushAllTags = false;
                if (tag == AllRefs)
                {
                    tag = "";
                    pushAllTags = true;
                }
                pushCmd = GitCommandHelpers.PushTagCmd(destination, tag, pushAllTags,
                                                       ForcePushBranches.Checked);
            }
            else
            {
                // Push Multiple Branches Tab selected
                var pushActions = new List<GitPushAction>();
                foreach (DataRow row in _branchTable.Rows)
                {
                    var push = Convert.ToBoolean(row["Push"]);
                    var force = Convert.ToBoolean(row["Force"]);
                    var delete = Convert.ToBoolean(row["Delete"]);

                    if (push || force)
                        pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force));
                    else if (delete)
                        pushActions.Add(new GitPushAction(row["Remote"].ToString()));
                }
                pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions);
            }

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            //controls can be accessed only from UI thread
            _selectedBranch = _NO_TRANSLATE_Branch.Text;
            _candidateForRebasingMergeCommit = PushToRemote.Checked && (_selectedBranch != AllRefs) && TabControlTagBranch.SelectedTab == BranchTab;
            _selectedBranchRemote = _NO_TRANSLATE_Remotes.Text;
            _selectedRemoteBranchName = RemoteBranch.Text;

            using (var form = new FormRemoteProcess(Module, pushCmd)
                       {
                           Remote = remote,
                           Text = string.Format(_pushToCaption.Text, destination),
                           HandleOnExitCallback = HandlePushOnExit
                       })
            {

                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                    if (_createPullRequestCB.Checked)
                        UICommands.StartCreatePullRequest(owner);
                    return true;
                }
            }

            return false;
        }
示例#23
0
        private bool PushChanges(IWin32Window owner)
        {
            ErrorOccurred = false;
            if (PushToUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
            {
                MessageBox.Show(owner, _selectDestinationDirectory.Text);
                return(false);
            }

            if (/* PushToRemote.Checked */ !CheckIfRemoteExist())
            {
                return(false);
            }

            var selectedRemoteName = _selectedRemote.Name;

            if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text))
            {
                MessageBox.Show(owner, _selectTag.Text);
                return(false);
            }

            // Extra check if the branch is already known to the remote, give a warning when not.
            // This is not possible when the remote is an URL, but this is ok since most users push to
            // known remotes anyway.
            if (TabControlTagBranch.SelectedTab == BranchTab && PushToRemote.Checked &&
                !Module.IsBareRepository())
            {
                // If the current branch is not the default push, and not known by the remote
                // (as far as we know since we are disconnected....)
                if (_NO_TRANSLATE_Branch.Text != AllRefs &&
                    RemoteBranch.Text != _remoteManager.GetDefaultPushRemote(_selectedRemote, _NO_TRANSLATE_Branch.Text) &&
                    !IsBranchKnownToRemote(selectedRemoteName, RemoteBranch.Text))
                {
                    // Ask if this is really what the user wants
                    if (!AppSettings.DontConfirmPushNewBranch &&
                        MessageBox.Show(owner, _branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            if (PushToUrl.Checked)
            {
                Repositories.AddMostRecentRepository(PushDestination.Text);
            }

            AppSettings.RecursiveSubmodules = RecursiveSubmodules.SelectedIndex;

            var    remote = "";
            string destination;

            if (PushToUrl.Checked)
            {
                destination = PushDestination.Text;
            }
            else
            {
                EnsurePageant(selectedRemoteName);

                destination = selectedRemoteName;
                remote      = selectedRemoteName.Trim();
            }

            string pushCmd;

            if (TabControlTagBranch.SelectedTab == BranchTab)
            {
                bool track = ReplaceTrackingReference.Checked;
                if (!track && !string.IsNullOrWhiteSpace(RemoteBranch.Text))
                {
                    GitRef selectedLocalBranch = _NO_TRANSLATE_Branch.SelectedItem as GitRef;
                    track = selectedLocalBranch != null && string.IsNullOrEmpty(selectedLocalBranch.TrackingRemote) &&
                            !UserGitRemotes.Any(x => _NO_TRANSLATE_Branch.Text.StartsWith(x.Name, StringComparison.OrdinalIgnoreCase));
                    var autoSetupMerge = Module.EffectiveConfigFile.GetValue("branch.autoSetupMerge");
                    if (autoSetupMerge.IsNotNullOrWhitespace() && autoSetupMerge.ToLowerInvariant() == "false")
                    {
                        track = false;
                    }

                    if (track && !AppSettings.DontConfirmAddTrackingRef)
                    {
                        var result = MessageBox.Show(this,
                                                     string.Format(_updateTrackingReference.Text, selectedLocalBranch.Name, RemoteBranch.Text),
                                                     _pushCaption.Text,
                                                     MessageBoxButtons.YesNoCancel);
                        if (result == DialogResult.Cancel)
                        {
                            return(false);
                        }

                        track = result == DialogResult.Yes;
                    }
                }

                if (ForcePushBranches.Checked)
                {
                    if (GitCommandHelpers.VersionInUse.SupportPushForceWithLease)
                    {
                        var choice = MessageBox.Show(this,
                                                     _useForceWithLeaseInstead.Text,
                                                     "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                                                     MessageBoxDefaultButton.Button1);
                        switch (choice)
                        {
                        case DialogResult.Yes:
                            ForcePushBranches.Checked = false;
                            ckForceWithLease.Checked  = true;
                            break;

                        case DialogResult.Cancel:
                            return(false);
                        }
                    }
                }

                if (_NO_TRANSLATE_Branch.Text == AllRefs)
                {
                    pushCmd = Module.PushAllCmd(destination, GetForcePushOption(), track, RecursiveSubmodules.SelectedIndex);
                }
                else
                {
                    pushCmd = Module.PushCmd(destination, _NO_TRANSLATE_Branch.Text, RemoteBranch.Text,
                                             GetForcePushOption(), track, RecursiveSubmodules.SelectedIndex);
                }
            }
            else if (TabControlTagBranch.SelectedTab == TagTab)
            {
                string tag         = TagComboBox.Text;
                bool   pushAllTags = false;
                if (tag == AllRefs)
                {
                    tag         = "";
                    pushAllTags = true;
                }

                pushCmd = GitCommandHelpers.PushTagCmd(destination, tag, pushAllTags, GetForcePushOption());
            }
            else
            {
                // Push Multiple Branches Tab selected
                var pushActions = new List <GitPushAction>();
                foreach (DataRow row in _branchTable.Rows)
                {
                    var push   = Convert.ToBoolean(row["Push"]);
                    var force  = Convert.ToBoolean(row["Force"]);
                    var delete = Convert.ToBoolean(row["Delete"]);

                    if (push || force)
                    {
                        pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force));
                    }
                    else if (delete)
                    {
                        pushActions.Add(GitPushAction.DeleteRemoteBranch(row["Remote"].ToString()));
                    }
                }

                pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions);
            }

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            // controls can be accessed only from UI thread
            _selectedBranch = _NO_TRANSLATE_Branch.Text;
            _candidateForRebasingMergeCommit = PushToRemote.Checked && (_selectedBranch != AllRefs) && TabControlTagBranch.SelectedTab == BranchTab;
            _selectedRemoteBranchName        = RemoteBranch.Text;

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                Remote = remote,
                Text = string.Format(_pushToCaption.Text, destination),
                HandleOnExitCallback = HandlePushOnExit
            })
            {
                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                    if (_createPullRequestCB.Checked)
                    {
                        UICommands.StartCreatePullRequest(owner);
                    }

                    return(true);
                }
            }

            return(false);
        }
示例#24
0
 private void mnuBtnPrune_Click(object sender, EventArgs e)
 {
     FormRemoteProcess.ShowDialog((GitModuleForm)ParentForm, "remote prune " + treeMain.SelectedNode.Name);
 }
示例#25
0
        private void LoadMultiBranchViewData(string remote)
        {
            using (WaitCursorScope.Enter(Cursors.AppStarting))
            {
                IReadOnlyList <IGitRef> remoteHeads;
                if (Module.EffectiveSettings.Detailed.GetRemoteBranchesDirectlyFromRemote.ValueOrDefault)
                {
                    EnsurePageant(remote);

                    var formProcess = new FormRemoteProcess(Module, $"ls-remote --heads \"{remote}\"")
                    {
                        Remote = remote
                    };

                    using (formProcess)
                    {
                        formProcess.ShowDialog(this);

                        if (formProcess.ErrorOccurred())
                        {
                            return;
                        }

                        var refList = CleanCommandOutput(formProcess.GetOutputString());

                        remoteHeads = Module.ParseRefs(refList);
                    }
                }
                else
                {
                    // use remote branches from git's local database if there were problems with receiving branches from the remote server
                    remoteHeads = Module.GetRemoteBranches().Where(r => r.Remote == remote).ToList();
                }

                ProcessHeads(remoteHeads);
            }

            return;

            string CleanCommandOutput(string processOutput)
            {
                // Command output consists of lines of format:
                //
                //     <SHA1> \t <full-ref>
                //
                // Such as:
                //
                //     fa77791d780a01a06d1f7d4ccad4ef93ed0ae2fd\trefs/heads/branchName

                int firstTabIdx = processOutput.IndexOf('\t');

                return(firstTabIdx == 40
                    ? processOutput
                    : firstTabIdx > 40
                        ? processOutput.Substring(firstTabIdx - 40)
                        : string.Empty);
            }

            void ProcessHeads(IReadOnlyList <IGitRef> remoteHeads)
            {
                var localHeads     = GetLocalBranches().ToList();
                var remoteBranches = remoteHeads.ToHashSet(h => h.LocalName);

                // Add all the local branches.
                foreach (var head in localHeads)
                {
                    var remoteName = head.Remote == remote
                        ? head.MergeWith ?? head.Name
                        : head.Name;
                    var isKnownAtRemote = remoteBranches.Contains(remoteName);

                    var row = _branchTable.NewRow();

                    row[ForceColumnName]  = false;
                    row[DeleteColumnName] = false;
                    row[LocalColumnName]  = head.Name;
                    row[RemoteColumnName] = remoteName;
                    row[NewColumnName]    = isKnownAtRemote ? _no.Text : _yes.Text;
                    row[PushColumnName]   = isKnownAtRemote;

                    _branchTable.Rows.Add(row);
                }

                // Offer to delete all the left over remote branches.
                foreach (var remoteHead in remoteHeads)
                {
                    if (localHeads.All(h => h.Name != remoteHead.LocalName))
                    {
                        var row = _branchTable.NewRow();

                        row[LocalColumnName]  = null;
                        row[RemoteColumnName] = remoteHead.LocalName;
                        row[NewColumnName]    = _no.Text;
                        row[PushColumnName]   = false;
                        row[ForceColumnName]  = false;
                        row[DeleteColumnName] = false;

                        _branchTable.Rows.Add(row);
                    }
                }

                BranchGrid.Enabled = true;
            }
        }
示例#26
0
        private FormProcess CreateFormProcess(string source, string curLocalBranch, string curRemoteBranch)
        {
            if (Fetch.Checked)
            {
                return(new FormRemoteProcess(UICommands, process: null, Module.FetchCmd(source, curRemoteBranch, curLocalBranch, GetTagsArg(), Unshallow.Checked, Prune.Checked, PruneTags.Checked)));
            }

            Debug.Assert(Merge.Checked || Rebase.Checked, "Merge.Checked || Rebase.Checked");

            return(new FormRemoteProcess(UICommands, process: null, Module.PullCmd(source, curRemoteBranch, Rebase.Checked, GetTagsArg(), Unshallow.Checked))
            {
                HandleOnExitCallback = HandlePullOnExit
            });

            bool?GetTagsArg()
            {
                return(AllTags.Checked ? true : NoTags.Checked?false : (bool?)null);
            }

            bool HandlePullOnExit(ref bool isError, FormProcess form)
            {
                if (!isError)
                {
                    return(false);
                }

                if (!PullFromRemote.Checked || string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
                {
                    return(false);
                }

                // auto pull only if current branch was rejected
                var isRefRemoved = new Regex(@"Your configuration specifies to .* the ref '.*'[\r]?\nfrom the remote, but no such ref was fetched.");

                if (isRefRemoved.IsMatch(form.GetOutputString()))
                {
                    using var dialog = new TaskDialog
                          {
                              OwnerWindowHandle = form.Handle,
                              Text            = _pruneBranchesBranch.Text,
                              Caption         = _pruneBranchesCaption.Text,
                              InstructionText = _pruneBranchesMainInstruction.Text,
                              StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No | TaskDialogStandardButtons.Cancel,
                              Icon            = TaskDialogStandardIcon.Information,
                              DefaultButton   = TaskDialogDefaultButton.No,
                              StartupLocation = TaskDialogStartupLocation.CenterOwner,
                          };
                    TaskDialogResult result = dialog.Show();

                    if (result == TaskDialogResult.Yes)
                    {
                        string remote   = _NO_TRANSLATE_Remotes.Text;
                        string pruneCmd = "remote prune " + remote;
                        using (var formPrune = new FormRemoteProcess(UICommands, process: null, pruneCmd)
                        {
                            Remote = remote,
                            Text = string.Format(_pruneFromCaption.Text, remote)
                        })
                        {
                            formPrune.ShowDialog(form);
                        }
                    }
                }

                return(false);
            }
        }
示例#27
0
        private void SaveClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(RemoteName.Text))
            {
                return;
            }

            var remote        = RemoteName.Text.Trim();
            var remoteUrl     = Url.Text.Trim();
            var remotePushUrl = comboBoxPushUrl.Text.Trim();

            try
            {
                // disable the control while saving
                tabControl1.Enabled = false;

                if ((string.IsNullOrEmpty(remotePushUrl) && checkBoxSepPushUrl.Checked) ||
                    remotePushUrl.Equals(remoteUrl, StringComparison.OrdinalIgnoreCase))
                {
                    checkBoxSepPushUrl.Checked = false;
                }

                // update all other remote properties
                var result = _remoteManager.SaveRemote(_selectedRemote,
                                                       remote,
                                                       remoteUrl,
                                                       checkBoxSepPushUrl.Checked ? remotePushUrl : null,
                                                       PuttySshKey.Text);

                if (!string.IsNullOrEmpty(result.UserMessage))
                {
                    MessageBox.Show(this, result.UserMessage, _gitMessage.Text);
                }
                else
                {
                    var remotes = Repositories.RemoteRepositoryHistory.Repositories;
                    RemoteUpdate(remotes, _selectedRemote?.Url, remoteUrl);
                    if (checkBoxSepPushUrl.Checked)
                    {
                        RemoteUpdate(remotes, _selectedRemote?.PushUrl, remotePushUrl);
                    }

                    Repositories.SaveSettings();
                }

                // if the user has just created a fresh new remote
                // there may be a need to configure it
                if (result.ShouldUpdateRemote &&
                    !string.IsNullOrEmpty(remoteUrl) &&
                    MessageBox.Show(this,
                                    _questionAutoPullBehaviour.Text,
                                    _questionAutoPullBehaviourCaption.Text,
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FormRemoteProcess.ShowDialog(this, "remote update");
                    _remoteManager.ConfigureRemotes(remote);
                }
            }
            finally
            {
                // re-enable the control and re-initialize
                tabControl1.Enabled = true;
                Initialize(remote);
            }
        }
 /// <summary>
 /// Re-applies the current options/rules to the WC.
 /// </summary>
 public void RefreshWorkingCopy()
 {
     // Re-apply tree to the index
     // TODO: check how it affects the uncommitted working copy changes
     using(var fromProcess = new FormRemoteProcess(_gitcommands.Module, AppSettings.GitCommand, RefreshWorkingCopyCommandName))
         fromProcess.ShowDialog(Form.ActiveForm);
 }
示例#29
0
        private void Clone(IHostedRepository repo)
        {
            string targetDir = GetTargetDir();
            if (targetDir == null)
                return;

            string repoSrc = repo.CloneReadWriteUrl;

            string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir);

            FormRemoteProcess formRemoteProcess = new FormRemoteProcess(new GitModule(null), AppSettings.GitCommand, cmd);
            formRemoteProcess.Remote = repoSrc;
            formRemoteProcess.ShowDialog();

            if (formRemoteProcess.ErrorOccurred())
                return;

            GitModule module = new GitModule(targetDir);

            if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl))
            {
                var error = module.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl);
                if (!string.IsNullOrEmpty(error))
                    MessageBox.Show(this, error, _strCouldNotAddRemote.Text);
            }

            if (GitModuleChanged != null)
                GitModuleChanged(this, new GitModuleEventArgs(module));

            Close();
        }
示例#30
0
 private void PruneClick(object sender, EventArgs e)
 {
     FormRemoteProcess.ShowDialog(this, "remote prune " + _remote);
 }
示例#31
0
        private bool HandlePullOnExit(ref bool isError, FormProcess form)
        {
            if (!isError)
                return false;

            if (!PullFromRemote.Checked || string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
                return false;

            //auto pull only if current branch was rejected
            Regex isRefRemoved = new Regex(@"Your configuration specifies to .* the ref '.*'[\r]?\nfrom the remote, but no such ref was fetched.");

            if (isRefRemoved.IsMatch(form.GetOutputString()))
            {
                int idx = PSTaskDialog.cTaskDialog.ShowCommandBox(form,
                                _pruneBranchesCaption.Text,
                                _pruneBranchesMainInstruction.Text,
                                _pruneBranchesBranch.Text,
                                _pruneBranchesButtons.Text,
                                true);
                if (idx == 0)
                {
                    string remote = _NO_TRANSLATE_Remotes.Text;
                    string pruneCmd = "remote prune " + remote;
                    using (var formPrune = new FormRemoteProcess(Module, pruneCmd)
                    {
                        Remote = remote,
                        Text = string.Format(_pruneFromCaption.Text, remote)
                    })
                    {

                        formPrune.ShowDialog(form);
                    }
                }

            }

            return false;
        }
示例#32
0
        private bool PushChanges(IWin32Window owner)
        {
            ErrorOccurred = false;
            if (PushToUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
            {
                MessageBox.Show(owner, _selectDestinationDirectory.Text);
                return(false);
            }
            if (PushToRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
            {
                MessageBox.Show(owner, _selectRemote.Text);
                return(false);
            }
            if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text))
            {
                MessageBox.Show(owner, _selectTag.Text);
                return(false);
            }

            //Extra check if the branch is already known to the remote, give a warning when not.
            //This is not possible when the remote is an URL, but this is ok since most users push to
            //known remotes anyway.
            if (TabControlTagBranch.SelectedTab == BranchTab && PushToRemote.Checked &&
                !Module.IsBareRepository())
            {
                //If the current branch is not the default push, and not known by the remote
                //(as far as we know since we are disconnected....)
                if (_NO_TRANSLATE_Branch.Text != AllRefs &&
                    RemoteBranch.Text != GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text, _NO_TRANSLATE_Branch.Text) &&
                    !IsBranchKnownToRemote(_NO_TRANSLATE_Remotes.Text, RemoteBranch.Text))
                {
                    //Ask if this is really what the user wants
                    if (!AppSettings.DontConfirmPushNewBranch &&
                        MessageBox.Show(owner, _branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) ==
                        DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            if (PushToUrl.Checked)
            {
                Repositories.AddMostRecentRepository(PushDestination.Text);
            }
            AppSettings.RecursiveSubmodules = RecursiveSubmodules.SelectedIndex;

            var    remote = "";
            string destination;

            if (PushToUrl.Checked)
            {
                destination = PushDestination.Text;
            }
            else
            {
                if (GitCommandHelpers.Plink())
                {
                    if (!File.Exists(AppSettings.Pageant))
                    {
                        MessageBoxes.PAgentNotFound(owner);
                    }
                    else
                    {
                        Module.StartPageantForRemote(_NO_TRANSLATE_Remotes.Text);
                    }
                }

                destination = _NO_TRANSLATE_Remotes.Text;
                remote      = _NO_TRANSLATE_Remotes.Text.Trim();
            }

            string pushCmd;

            if (TabControlTagBranch.SelectedTab == BranchTab)
            {
                bool track = ReplaceTrackingReference.Checked;
                if (!track && !string.IsNullOrWhiteSpace(RemoteBranch.Text))
                {
                    GitRef selectedLocalBranch = _NO_TRANSLATE_Branch.SelectedItem as GitRef;
                    track = selectedLocalBranch != null && string.IsNullOrEmpty(selectedLocalBranch.TrackingRemote);

                    string[] remotes = _NO_TRANSLATE_Remotes.DataSource as string[];
                    if (remotes != null)
                    {
                        foreach (string remoteBranch in remotes)
                        {
                            if (!string.IsNullOrEmpty(remoteBranch) && _NO_TRANSLATE_Branch.Text.StartsWith(remoteBranch))
                            {
                                track = false;
                            }
                        }
                    }

                    if (track && !AppSettings.DontConfirmAddTrackingRef)
                    {
                        DialogResult result = MessageBox.Show(String.Format(_updateTrackingReference.Text, selectedLocalBranch.Name, RemoteBranch.Text), _pushCaption.Text, MessageBoxButtons.YesNoCancel);

                        if (result == DialogResult.Cancel)
                        {
                            return(false);
                        }

                        track = result == DialogResult.Yes;
                    }
                }

                if (_NO_TRANSLATE_Branch.Text == AllRefs)
                {
                    pushCmd = Module.PushAllCmd(destination, ForcePushBranches.Checked, track,
                                                RecursiveSubmodules.SelectedIndex);
                }
                else
                {
                    pushCmd = Module.PushCmd(destination, _NO_TRANSLATE_Branch.Text, RemoteBranch.Text,
                                             ForcePushBranches.Checked, track, RecursiveSubmodules.SelectedIndex);
                }
            }
            else if (TabControlTagBranch.SelectedTab == TagTab)
            {
                string tag         = TagComboBox.Text;
                bool   pushAllTags = false;
                if (tag == AllRefs)
                {
                    tag         = "";
                    pushAllTags = true;
                }
                pushCmd = GitCommandHelpers.PushTagCmd(destination, tag, pushAllTags,
                                                       ForcePushBranches.Checked);
            }
            else
            {
                // Push Multiple Branches Tab selected
                var pushActions = new List <GitPushAction>();
                foreach (DataRow row in _branchTable.Rows)
                {
                    var push   = Convert.ToBoolean(row["Push"]);
                    var force  = Convert.ToBoolean(row["Force"]);
                    var delete = Convert.ToBoolean(row["Delete"]);

                    if (push || force)
                    {
                        pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force));
                    }
                    else if (delete)
                    {
                        pushActions.Add(GitPushAction.DeleteRemoteBranch(row["Remote"].ToString()));
                    }
                }
                pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions);
            }

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            //controls can be accessed only from UI thread
            _selectedBranch = _NO_TRANSLATE_Branch.Text;
            _candidateForRebasingMergeCommit = PushToRemote.Checked && (_selectedBranch != AllRefs) && TabControlTagBranch.SelectedTab == BranchTab;
            _selectedBranchRemote            = _NO_TRANSLATE_Remotes.Text;
            _selectedRemoteBranchName        = RemoteBranch.Text;

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                Remote = remote,
                Text = string.Format(_pushToCaption.Text, destination),
                HandleOnExitCallback = HandlePushOnExit
            })
            {
                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                    if (_createPullRequestCB.Checked)
                    {
                        UICommands.StartCreatePullRequest(owner);
                    }
                    return(true);
                }
            }

            return(false);
        }
示例#33
0
        private bool PushChanges(IWin32Window owner)
        {
            ErrorOccurred = false;
            if (PushToUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
            {
                MessageBox.Show(owner, _selectDestinationDirectory.Text);
                return false;
            }
            if (PushToRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text))
            {
                MessageBox.Show(owner, _selectRemote.Text);
                return false;
            }
            if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text))
            {
                MessageBox.Show(owner, _selectTag.Text);
                return false;
            }

            //Extra check if the branch is already known to the remote, give a warning when not.
            //This is not possible when the remote is an URL, but this is ok since most users push to
            //known remotes anyway.
            if (TabControlTagBranch.SelectedTab == BranchTab && PushToRemote.Checked &&
                !Module.IsBareRepository())
            {
                //If the current branch is not the default push, and not known by the remote
                //(as far as we know since we are disconnected....)
                if (_NO_TRANSLATE_Branch.Text != AllRefs &&
                    RemoteBranch.Text != GetDefaultPushRemote(_NO_TRANSLATE_Remotes.Text, _NO_TRANSLATE_Branch.Text) &&
                    !IsBranchKnownToRemote(_NO_TRANSLATE_Remotes.Text, RemoteBranch.Text))
                {
                    //Ask if this is really what the user wants
                    if (!AppSettings.DontConfirmPushNewBranch &&
                        MessageBox.Show(owner, _branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) ==
                            DialogResult.No)
                    {
                        return false;
                    }
                }
            }

            if (PushToUrl.Checked)
                Repositories.AddMostRecentRepository(PushDestination.Text);
            AppSettings.RecursiveSubmodules = RecursiveSubmodules.SelectedIndex;

            var remote = "";
            string destination;
            if (PushToUrl.Checked)
            {
                destination = PushDestination.Text;
            }
            else
            {
                EnsurePageant(_NO_TRANSLATE_Remotes.Text);

                destination = _NO_TRANSLATE_Remotes.Text;
                remote = _NO_TRANSLATE_Remotes.Text.Trim();
            }

            string pushCmd;
            if (TabControlTagBranch.SelectedTab == BranchTab)
            {
                bool track = ReplaceTrackingReference.Checked;
                if (!track && !string.IsNullOrWhiteSpace(RemoteBranch.Text))
                {
                    GitRef selectedLocalBranch = _NO_TRANSLATE_Branch.SelectedItem as GitRef;
                    track = selectedLocalBranch != null && string.IsNullOrEmpty(selectedLocalBranch.TrackingRemote);

                    string[] remotes = _NO_TRANSLATE_Remotes.DataSource as string[];
                    if (remotes != null)
                        foreach (string remoteBranch in remotes)
                            if (!string.IsNullOrEmpty(remoteBranch) && _NO_TRANSLATE_Branch.Text.StartsWith(remoteBranch))
                                track = false;
                    var autoSetupMerge = Module.EffectiveConfigFile.GetValue("branch.autoSetupMerge");
                    if (autoSetupMerge.IsNotNullOrWhitespace() && autoSetupMerge.ToLowerInvariant() == "false")
                    {
                        track = false;
                    }
                    if (track && !AppSettings.DontConfirmAddTrackingRef)
                    {
                        DialogResult result = MessageBox.Show(String.Format(_updateTrackingReference.Text, selectedLocalBranch.Name, RemoteBranch.Text), _pushCaption.Text, MessageBoxButtons.YesNoCancel);

                        if (result == DialogResult.Cancel)
                            return false;

                        track = result == DialogResult.Yes;
                    }
                }

                if (ForcePushBranches.Checked)
                {
                    if (GitCommandHelpers.VersionInUse.SupportPushForceWithLease)
                    {
                        var choice = MessageBox.Show(this,
                            _useForceWithLeaseInstead.Text,
                            "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                        switch (choice)
                        {
                            case DialogResult.Yes:
                                ForcePushBranches.Checked = false;
                                ckForceWithLease.Checked = true;
                                break;
                            case DialogResult.Cancel:
                                return false;
                        }
                    }
                }

                if (_NO_TRANSLATE_Branch.Text == AllRefs)
                {
                    pushCmd = Module.PushAllCmd(destination, GetForcePushOption(), track,
                        RecursiveSubmodules.SelectedIndex);
                }
                else
                {
                    pushCmd = Module.PushCmd(destination, _NO_TRANSLATE_Branch.Text, RemoteBranch.Text,
                        GetForcePushOption(), track, RecursiveSubmodules.SelectedIndex);
                }
            }
            else if (TabControlTagBranch.SelectedTab == TagTab)
            {
                string tag = TagComboBox.Text;
                bool pushAllTags = false;
                if (tag == AllRefs)
                {
                    tag = "";
                    pushAllTags = true;
                }
                pushCmd = GitCommandHelpers.PushTagCmd(destination, tag, pushAllTags,
                                                       GetForcePushOption());
            }
            else
            {
                // Push Multiple Branches Tab selected
                var pushActions = new List<GitPushAction>();
                foreach (DataRow row in _branchTable.Rows)
                {
                    var push = Convert.ToBoolean(row["Push"]);
                    var force = Convert.ToBoolean(row["Force"]);
                    var delete = Convert.ToBoolean(row["Delete"]);

                    if (push || force)
                        pushActions.Add(new GitPushAction(row["Local"].ToString(), row["Remote"].ToString(), force));
                    else if (delete)
                        pushActions.Add(GitPushAction.DeleteRemoteBranch(row["Remote"].ToString()));
                }
                pushCmd = GitCommandHelpers.PushMultipleCmd(destination, pushActions);
            }

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforePush);

            //controls can be accessed only from UI thread
            _selectedBranch = _NO_TRANSLATE_Branch.Text;
            _candidateForRebasingMergeCommit = PushToRemote.Checked && (_selectedBranch != AllRefs) && TabControlTagBranch.SelectedTab == BranchTab;
            _selectedBranchRemote = _NO_TRANSLATE_Remotes.Text;
            _selectedRemoteBranchName = RemoteBranch.Text;

            using (var form = new FormRemoteProcess(Module, pushCmd)
                       {
                           Remote = remote,
                           Text = string.Format(_pushToCaption.Text, destination),
                           HandleOnExitCallback = HandlePushOnExit
                       })
            {

                form.ShowDialog(owner);
                ErrorOccurred = form.ErrorOccurred();

                if (!Module.InTheMiddleOfAction() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(this, ScriptEvent.AfterPush);
                    if (_createPullRequestCB.Checked)
                        UICommands.StartCreatePullRequest(owner);
                    return true;
                }
            }

            return false;
        }
示例#34
0
        private void PushTag(string tagName)
        {
            var pushCmd = GitCommandHelpers.PushTagCmd(_currentRemote, tagName, false);

            ScriptManager.RunEventScripts(Module, ScriptEvent.BeforePush);

            using (var form = new FormRemoteProcess(Module, pushCmd)
            {
                Remote = _currentRemote,
                Text = string.Format(_pushToCaption.Text, _currentRemote),
            })
            {

                form.ShowDialog();

                if (!Module.InTheMiddleOfConflictedMerge() &&
                    !Module.InTheMiddleOfRebase() && !form.ErrorOccurred())
                {
                    ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPush);
                }
            }
        }
示例#35
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Default;
                _branchListLoader.Cancel();

                var dirTo = Path.Combine(_NO_TRANSLATE_To.Text, _NO_TRANSLATE_NewDirectory.Text);

                Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text);

                if (!Directory.Exists(dirTo))
                    Directory.CreateDirectory(dirTo);

                // Shallow clone params
                int? depth = null;
                bool? isSingleBranch = null;
                if(!cbDownloadFullHistory.Checked)
                {
                    depth = 1;
                    // Single branch considerations:
                    // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default.
                    // If depth is specified, then single-branch is assumed.
                    // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption).
                    // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches.
                    isSingleBranch = false;
                }

                // Branch name param
                string branch = _NO_TRANSLATE_Branches.Text;
                if(branch == _branchDefaultRemoteHead.Text)
                    branch = "";
                else if(branch == _branchNone.Text)
                    branch = null;

                var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                            CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch);
                using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd))
                {
                    fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                    fromProcess.ShowDialog(this);

                    if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch())
                        return;
                }

                Repositories.AddMostRecentRepository(dirTo);

                if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Hide();
                    GitUICommands uiCommands = new GitUICommands(dirTo);
                    uiCommands.StartBrowseDialog();
                }
                else if (ShowInTaskbar == false && GitModuleChanged != null &&
                    AskIfNewRepositoryShouldBeOpened(dirTo))
                    GitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo)));

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#36
0
 private void UpdateBranchClick(object sender, EventArgs e)
 {
     FormRemoteProcess.ShowDialog(this, "remote update");
 }
示例#37
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Default;
                _branchListLoader.Cancel();

                var dirTo = _NO_TRANSLATE_To.Text;
                if (!dirTo.EndsWith(AppSettings.PathSeparator.ToString()) && !dirTo.EndsWith(AppSettings.PathSeparatorWrong.ToString()))
                    dirTo += AppSettings.PathSeparator.ToString();

                dirTo += _NO_TRANSLATE_NewDirectory.Text;

                Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text);
                Repositories.AddMostRecentRepository(dirTo);

                if (!Directory.Exists(dirTo))
                    Directory.CreateDirectory(dirTo);

                var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                            CentralRepository.Checked, cbIntializeAllSubmodules.Checked, Branches.Text, null);
                using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd))
                {
                    fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                    fromProcess.ShowDialog(this);

                    if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch())
                        return;
                }

                if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Hide();
                    GitUICommands uiCommands = new GitUICommands(dirTo);
                    uiCommands.StartBrowseDialog();
                }
                else if (ShowInTaskbar == false && GitModuleChanged != null &&
                    AskIfNewRepositoryShouldBeOpened(dirTo))
                    GitModuleChanged(new GitModule(dirTo));

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#38
0
 private void mnuBtnPruneAllRemotes_Click(object sender, EventArgs e)
 {
     FormRemoteProcess.ShowDialog((GitModuleForm)ParentForm, "remote update --prune");
 }
示例#39
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Default;
                _branchListLoader.Cancel();

                // validate if destination path is supplied
                var destination = _NO_TRANSLATE_To.Text;
                if (string.IsNullOrWhiteSpace(destination))
                {
                    MessageBox.Show(this, _errorDestinationNotSupplied.Text, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _NO_TRANSLATE_To.Focus();
                    return;
                }

                if (!Path.IsPathRooted(destination))
                {
                    MessageBox.Show(this, _errorDestinationNotRooted.Text, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _NO_TRANSLATE_To.Focus();
                    return;
                }

                var dirTo = Path.Combine(destination, _NO_TRANSLATE_NewDirectory.Text);

                // this will fail if the path is anyhow invalid
                dirTo = new Uri(dirTo).LocalPath;

                if (!Directory.Exists(dirTo))
                {
                    Directory.CreateDirectory(dirTo);
                }

                // Shallow clone params
                int? depth          = null;
                bool?isSingleBranch = null;
                if (!cbDownloadFullHistory.Checked)
                {
                    depth = 1;

                    // Single branch considerations:
                    // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default.
                    // If depth is specified, then single-branch is assumed.
                    // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption).
                    // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches.
                    isSingleBranch = false;
                }

                // Branch name param
                string branch = _NO_TRANSLATE_Branches.Text;
                if (branch == _branchDefaultRemoteHead.Text)
                {
                    branch = "";
                }
                else if (branch == _branchNone.Text)
                {
                    branch = null;
                }

                var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                                                          CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch, cbLfs.Checked);
                using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd))
                {
                    fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                    fromProcess.ShowDialog(this);

                    if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch())
                    {
                        return;
                    }
                }

                ThreadHelper.JoinableTaskFactory.Run(() => RepositoryHistoryManager.Locals.AddAsMostRecentAsync(dirTo));
                if (!string.IsNullOrEmpty(_puttySshKey))
                {
                    var clonedGitModule = new GitModule(dirTo);
                    clonedGitModule.SetSetting(string.Format(SettingKeyString.RemotePuttySshKey, "origin"), _puttySshKey);
                    clonedGitModule.LocalConfigFile.Save();
                }

                if (_openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Hide();
                    var uiCommands = new GitUICommands(dirTo);
                    uiCommands.StartBrowseDialog();
                }
                else if (ShowInTaskbar == false && _gitModuleChanged != null &&
                         AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    _gitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo)));
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, _errorCloneFailed.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#40
0
        private void SaveClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(RemoteName.Text))
            {
                return;
            }

            var remote        = RemoteName.Text.Trim();
            var remoteUrl     = Url.Text.Trim();
            var remotePushUrl = comboBoxPushUrl.Text.Trim();

            try
            {
                // disable the control while saving
                tabControl1.Enabled = false;

                if ((string.IsNullOrEmpty(remotePushUrl) && checkBoxSepPushUrl.Checked) ||
                    (!string.IsNullOrEmpty(remotePushUrl) && remotePushUrl.Equals(remoteUrl, StringComparison.OrdinalIgnoreCase)))
                {
                    checkBoxSepPushUrl.Checked = false;
                }

                if (_remoteManager.EnabledRemoteExists(remote))
                {
                    MessageBox.Show(this, string.Format(_enabledRemoteAlreadyExists.Text, remote), _gitMessage.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (_remoteManager.DisabledRemoteExists(remote))
                {
                    MessageBox.Show(this, string.Format(_disabledRemoteAlreadyExists.Text, remote), _gitMessage.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // update all other remote properties
                var result = _remoteManager.SaveRemote(_selectedRemote,
                                                       remote,
                                                       remoteUrl,
                                                       checkBoxSepPushUrl.Checked ? remotePushUrl : null,
                                                       PuttySshKey.Text);

                if (!string.IsNullOrEmpty(result.UserMessage))
                {
                    MessageBox.Show(this, result.UserMessage, _gitMessage.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {
                    ThreadHelper.JoinableTaskFactory.Run(async() =>
                    {
                        var repositoryHistory = await RepositoryHistoryManager.Remotes.LoadRecentHistoryAsync();

                        await this.SwitchToMainThreadAsync();
                        RemoteUpdate(repositoryHistory, _selectedRemote?.Url, remoteUrl);
                        if (checkBoxSepPushUrl.Checked)
                        {
                            RemoteUpdate(repositoryHistory, _selectedRemote?.PushUrl, remotePushUrl);
                        }

                        await RepositoryHistoryManager.Remotes.SaveRecentHistoryAsync(repositoryHistory);
                    });
                }

                // if the user has just created a fresh new remote
                // there may be a need to configure it
                if (result.ShouldUpdateRemote &&
                    !string.IsNullOrEmpty(remoteUrl) &&
                    MessageBox.Show(this,
                                    _questionAutoPullBehaviour.Text,
                                    _questionAutoPullBehaviourCaption.Text,
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FormRemoteProcess.ShowDialog(this, "remote update");
                    _remoteManager.ConfigureRemotes(remote);
                    UICommands.RepoChangedNotifier.Notify();
                }
            }
            finally
            {
                // re-enable the control and re-initialize
                tabControl1.Enabled = true;
                Initialize(remote);
            }
        }
示例#41
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Default;
                _branchListLoader.Cancel();

                var dirTo = Path.Combine(_NO_TRANSLATE_To.Text, _NO_TRANSLATE_NewDirectory.Text);

                Repositories.AddMostRecentRepository(_NO_TRANSLATE_From.Text);

                if (!Directory.Exists(dirTo))
                {
                    Directory.CreateDirectory(dirTo);
                }

                // Shallow clone params
                int? depth          = null;
                bool?isSingleBranch = null;
                if (!cbDownloadFullHistory.Checked)
                {
                    depth = 1;
                    // Single branch considerations:
                    // If neither depth nor single-branch family params are specified, then it's like no-single-branch by default.
                    // If depth is specified, then single-branch is assumed.
                    // But with single-branch it's really nontrivial to switch to another branch in the GUI, and it's very hard in cmdline (obvious choices to fetch another branch lead to local repo corruption).
                    // So let's reset it to no-single-branch to (a) have the same branches behavior as with full clone, and (b) make it easier for users when switching branches.
                    isSingleBranch = false;
                }

                // Branch name param
                string branch = _NO_TRANSLATE_Branches.Text;
                if (branch == _branchDefaultRemoteHead.Text)
                {
                    branch = "";
                }
                else if (branch == _branchNone.Text)
                {
                    branch = null;
                }

                var cloneCmd = GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                                                          CentralRepository.Checked, cbIntializeAllSubmodules.Checked, branch, depth, isSingleBranch);
                using (var fromProcess = new FormRemoteProcess(Module, AppSettings.GitCommand, cloneCmd))
                {
                    fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                    fromProcess.ShowDialog(this);

                    if (fromProcess.ErrorOccurred() || Module.InTheMiddleOfPatch())
                    {
                        return;
                    }
                }

                Repositories.AddMostRecentRepository(dirTo);

                if (openedFromProtocolHandler && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Hide();
                    GitUICommands uiCommands = new GitUICommands(dirTo);
                    uiCommands.StartBrowseDialog();
                }
                else if (ShowInTaskbar == false && GitModuleChanged != null &&
                         AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    GitModuleChanged(this, new GitModuleEventArgs(new GitModule(dirTo)));
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }