public bool PullChanges() { if (PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text)) { MessageBox.Show(_selectSourceDirectory.Text); return(false); } if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text) && !PullAll()) { MessageBox.Show(_selectRemoteRepository.Text); return(false); } if (!Fetch.Checked && Branches.Text == "*") { MessageBox.Show(_fetchAllBranchesCanOnlyWithFetch.Text); return(false); } if (Merge.Checked) { Settings.PullMerge = "merge"; } if (Rebase.Checked) { Settings.PullMerge = "rebase"; } if (Fetch.Checked) { Settings.PullMerge = "fetch"; } Settings.AutoStash = AutoStash.Checked; Repositories.RepositoryHistory.AddMostRecentRepository(PullSource.Text); string source; if (PullFromUrl.Checked) { source = PullSource.Text; } else { LoadPuttyKey(); source = PullAll() ? "--all" : Remotes.Text; } ScriptManager.RunEventScripts(ScriptEvent.BeforePull); var stashed = false; if (!Fetch.Checked && AutoStash.Checked && GitCommandHelpers.GitStatus(false).Count > 0) { new FormProcess("stash save").ShowDialog(); stashed = true; } FormProcess process = null; if (Fetch.Checked) { process = new FormProcess(GitCommandHelpers.FetchCmd(source, Branches.Text, null)); } else { string localBranch = GitCommandHelpers.GetSelectedBranch(); if (localBranch.Equals("(no branch)", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(Branches.Text)) { localBranch = null; } if (Merge.Checked) { process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, false)); } else if (Rebase.Checked) { process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, true)); } } if (process != null) { process.ShowDialog(); } try { if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase() && (process != null && !process.ErrorOccurred())) { return(true); } // Rebase failed -> special 'rebase' merge conflict if (Rebase.Checked && GitCommandHelpers.InTheMiddleOfRebase()) { GitUICommands.Instance.StartRebaseDialog(null); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } } else { MergeConflictHandler.HandleMergeConflicts(); if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() && !GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } } if (!AutoStash.Checked || !stashed || GitCommandHelpers.InTheMiddleOfConflictedMerge() || GitCommandHelpers.InTheMiddleOfRebase()) { return(true); } if (MessageBox.Show(_applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) != DialogResult.Yes) { return(true); } if (stashed) { new FormProcess("stash pop").ShowDialog(); } MergeConflictHandler.HandleMergeConflicts(); } finally { ScriptManager.RunEventScripts(ScriptEvent.AfterPull); } return(false); }