private void FormatPatch_Click(object sender, EventArgs e)
        {
            string rev1 = "";
            string rev2 = "";

            if (RevisionGrid.GetRevisions().Count > 0)
            {
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[0].Guid;
                }

                if (RevisionGrid.GetRevisions().Count == 2)
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[1].Guid;
                }
            }
            if (string.IsNullOrEmpty(rev1) || string.IsNullOrEmpty(rev2))
            {
                MessageBox.Show("You need to select 2 revisions", "Patch error");
                return;
            }

            string result = new GitCommands.GitCommands().FormatPatch(rev1, rev2, OutputPath.Text);

            MessageBox.Show(result, "Patch result");
        }
Beispiel #2
0
        public void Execute()
        {
            Revisions = new List<GitRevision>();

            heads = GitCommands.GetHeads(true);

            if (!LogParam.Contains("=") && Settings.ShowRevisionGraph)
                LogParam = " --graph " + LogParam;

            if (Settings.OrderRevisionByDate)
                LogParam = " --date-order " + LogParam;

            string dateFormat;
            if (Settings.RelativeDate)
                dateFormat = "%cr";
            else
                dateFormat = "%cd";

            gitGetGraphCommand = new GitCommands();
            gitGetGraphCommand.CollectOutput = false;
            gitGetGraphCommand.CmdStartProcess(Settings.GitDir + "git.cmd", "log -n " + LimitRevisions + " --pretty=format:\"Commit %H %nTree:   %T%nAuthor: %aN %nDate:   " + dateFormat + " %nParents:%P %n%s\" " + LogParam);

            gitGetGraphCommand.DataReceived += new System.Diagnostics.DataReceivedEventHandler(gitGetGraphCommand_DataReceived);
            gitGetGraphCommand.Exited += new EventHandler(gitGetGraphCommand_Exited);
        }
Beispiel #3
0
        public void Execute()
        {
            Revisions = new List<GitRevision>();

            heads = GitCommands.GetHeads(true);

            gitGetGraphCommand = new GitCommands();
            gitGetGraphCommand.CollectOutput = false;
            gitGetGraphCommand.CmdStartProcess(Settings.GitDir + "git.cmd", "log -n " + LimitRevisions + " --graph --all --pretty=format:\"Commit %H %nTree:   %T%nAuthor: %aN %nDate:   %cd %nParents:%P %n%s\"");

            gitGetGraphCommand.DataReceived += new System.Diagnostics.DataReceivedEventHandler(gitGetGraphCommand_DataReceived);
            gitGetGraphCommand.Exited += new EventHandler(gitGetGraphCommand_Exited);
        }
        public AdvancedSettingsPage()
        {
            InitializeComponent();
            Text = "Advanced";
            Translate();

            var autoNormaliseSymbols = new[] {
                new { Key =  "_", Value = "_" },
                new { Key =  "-", Value = "-" },
                new { Key =  "(none)", Value = "" },
            };
            cboAutoNormaliseSymbol.DataSource = autoNormaliseSymbols;
            cboAutoNormaliseSymbol.SelectedIndex = 0;
        }
        public static bool SolveKDiff()
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            string mergeTool = gitCommands.GetGlobalSetting("merge.tool");
            if (string.IsNullOrEmpty(mergeTool))
            {
                mergeTool = "kdiff3";
                gitCommands.SetGlobalSetting("merge.tool", mergeTool);
            }

            if (mergeTool.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
                return SolveKDiffPath(gitCommands);

            return true;
        }
Beispiel #6
0
        private void FormatPatch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(OutputPath.Text))
                MessageBox.Show("You need to enter an output path.");

            string rev1 = "";
            string rev2 = "";
            string result = "";

            if (RevisionGrid.GetRevisions().Count > 0)
            {
                if (RevisionGrid.GetRevisions().Count == 1)
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[0].Guid;
                    result = new GitCommands.GitCommands().FormatPatch(rev1, rev2, OutputPath.Text);
                }

                if (RevisionGrid.GetRevisions().Count == 2)
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[1].Guid;
                    result = new GitCommands.GitCommands().FormatPatch(rev1, rev2, OutputPath.Text);
                }

                if (RevisionGrid.GetRevisions().Count > 2)
                {
                    int n = 0;
                    foreach (GitRevision revision in RevisionGrid.GetRevisions())
                    {
                        n++;
                        rev1 = revision.ParentGuids[0];
                        rev2 = revision.Guid;
                        result += new GitCommands.GitCommands().FormatPatch(rev1, rev2, OutputPath.Text, n);
                    }
                }
            } else
            if (string.IsNullOrEmpty(rev1) || string.IsNullOrEmpty(rev2))
            {
                MessageBox.Show("You need to select 2 revisions", "Patch error");
                return;
            }

            MessageBox.Show(result, "Patch result");
            Close();
        }
        public void Execute()
        {
            Revisions = new List<GitRevision>();

            heads = GitCommands.GetHeads(true);

            if (!LogParam.Contains("=") && Settings.ShowRevisionGraph)
                LogParam = " --graph " + LogParam;

            if (Settings.OrderRevisionByDate)
                LogParam = " --date-order " + LogParam;

            string dateFormat;
            if (Settings.RelativeDate)
                dateFormat = "r";
            else
                dateFormat = "d";

            string limitRevisionsArgument;
            if (LogParam.Contains("--follow"))
                limitRevisionsArgument = "";
            else
                limitRevisionsArgument = " -n " + LimitRevisions;

            string arguments = String.Format(CultureInfo.InvariantCulture,
                "log{0} --pretty=format:\"Commit %H %nTree: %T %nAuthor: %aN %nAuthorDate: %a{1} %nCommitter: %cN %nCommitDate: %c{1} %nParents: %P %n%s\" {2}",
                limitRevisionsArgument,
                dateFormat,
                LogParam);

            gitGetGraphCommand = new GitCommands();
            gitGetGraphCommand.CollectOutput = false;
            gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

            gitGetGraphCommand.DataReceived += new System.Diagnostics.DataReceivedEventHandler(gitGetGraphCommand_DataReceived);
            gitGetGraphCommand.Exited += new EventHandler(gitGetGraphCommand_Exited);
        }
Beispiel #8
0
        private bool Save()
        {
            GitCommands.Settings.FollowRenamesInFileHistory = FollowRenamesInFileHistory.Checked;

            GitCommands.Settings.Smtp = SmtpServer.Text;

            GitCommands.Settings.GitDir = GitPath.Text;
            GitCommands.Settings.GitBinDir = GitBinPath.Text;

            GitCommands.Settings.CloseProcessDialog = CloseProcessDialog.Checked;
            GitCommands.Settings.ShowRevisionGraph = ShowRevisionGraph.Checked;
            GitCommands.Settings.ShowGitCommandLine = ShowGitCommandLine.Checked;

            GitCommands.Settings.UseFastChecks = UseFastChecks.Checked;
            GitCommands.Settings.RelativeDate = ShowRelativeDate.Checked;

            GitCommands.Settings.Dictionary = Dictionary.Text;

            GitCommands.Settings.MaxCommits = (int)MaxCommits.Value;

            GitCommands.Settings.Plink = PlinkPath.Text;
            GitCommands.Settings.Puttygen = PuttygenPath.Text;
            GitCommands.Settings.Pageant = PageantPath.Text;
            GitCommands.Settings.AutoStartPageant = AutostartPageant.Checked;

            if (string.IsNullOrEmpty(Encoding.Text) || Encoding.Text.Equals("Default", StringComparison.CurrentCultureIgnoreCase))
                GitCommands.Settings.Encoding = System.Text.Encoding.Default;
            else
                if (Encoding.Text.Equals("ASCII", StringComparison.CurrentCultureIgnoreCase))
                    GitCommands.Settings.Encoding = new ASCIIEncoding();
                else
                    if (Encoding.Text.Equals("Unicode", StringComparison.CurrentCultureIgnoreCase))
                        GitCommands.Settings.Encoding = new UnicodeEncoding();
                    else
                        if (Encoding.Text.Equals("UTF7", StringComparison.CurrentCultureIgnoreCase))
                            GitCommands.Settings.Encoding = new UTF7Encoding();
                        else
                            if (Encoding.Text.Equals("UTF8", StringComparison.CurrentCultureIgnoreCase))
                                GitCommands.Settings.Encoding = new UTF8Encoding(false);
                            else
                                if (Encoding.Text.Equals("UTF32", StringComparison.CurrentCultureIgnoreCase))
                                    GitCommands.Settings.Encoding = new UTF32Encoding(true, false);
                                else
                                    GitCommands.Settings.Encoding = System.Text.Encoding.Default;

            Settings.RevisionGraphColor = RevisionGraphColorLabel.BackColor;
            Settings.RevisionGraphColorSelected = RevisionGraphColorSelected.BackColor;
            Settings.TagColor = ColorTagLabel.BackColor;
            Settings.BranchColor = ColorBranchLabel.BackColor;
            Settings.RemoteBranchColor = ColorRemoteBranchLabel.BackColor;
            Settings.OtherTagColor = ColorOtherLabel.BackColor;

            Settings.DiffAddedColor = ColorAddedLineLabel.BackColor;
            Settings.DiffRemovedColor = ColorRemovedLine.BackColor;
            Settings.DiffSectionColor = ColorSectionLabel.BackColor;

            EnableSettings();

            if (!CanFindGitCmd())
            {
                if (MessageBox.Show("The path to git.cmd is not configured correct." + Environment.NewLine + "You need to set the correct path to be able to use GitExtensions." + Environment.NewLine + Environment.NewLine + "Do you want to set the correct path now?", "Incorrect path", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    return false;
            }
            else
            {
                GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

                if (string.IsNullOrEmpty(UserName.Text) || !UserName.Text.Equals(GitCommands.GitCommands.GetSetting("user.name")))
                    GitCommands.GitCommands.SetSetting("user.name", UserName.Text);
                if (string.IsNullOrEmpty(UserEmail.Text) || !UserEmail.Text.Equals(GitCommands.GitCommands.GetSetting("user.email")))
                    GitCommands.GitCommands.SetSetting("user.email", UserEmail.Text);
                GitCommands.GitCommands.SetSetting("core.editor", Editor.Text);
                GitCommands.GitCommands.SetSetting("merge.tool", MergeTool.Text);

                if (KeepMergeBackup.CheckState == CheckState.Checked)
                    GitCommands.GitCommands.SetSetting("mergetool.keepBackup", "true");
                else
                    if (KeepMergeBackup.CheckState == CheckState.Unchecked)
                        GitCommands.GitCommands.SetSetting("mergetool.keepBackup", "false");

                GitCommands.GitCommands.SetSetting("core.autocrlf", LocalAutoCRLF.SelectedItem as string);

                if (string.IsNullOrEmpty(GlobalUserName.Text) || !GlobalUserName.Text.Equals(gitCommands.GetGlobalSetting("user.name")))
                    gitCommands.SetGlobalSetting("user.name", GlobalUserName.Text);
                if (string.IsNullOrEmpty(GlobalUserEmail.Text) || !GlobalUserEmail.Text.Equals(gitCommands.GetGlobalSetting("user.email")))
                    gitCommands.SetGlobalSetting("user.email", GlobalUserEmail.Text);
                gitCommands.SetGlobalSetting("core.editor", GlobalEditor.Text);
                gitCommands.SetGlobalSetting("merge.tool", GlobalMergeTool.Text);

                if (!string.IsNullOrEmpty(GlobalMergeTool.Text))
                    gitCommands.SetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".path", MergetoolPath.Text);
                if (!string.IsNullOrEmpty(GlobalMergeTool.Text))
                    gitCommands.SetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".cmd", MergeToolCmd.Text);

                if (GlobalKeepMergeBackup.CheckState == CheckState.Checked)
                    gitCommands.SetGlobalSetting("mergetool.keepBackup", "true");
                else
                    if (GlobalKeepMergeBackup.CheckState == CheckState.Unchecked)
                        gitCommands.SetGlobalSetting("mergetool.keepBackup", "false");

                gitCommands.SetGlobalSetting("core.autocrlf", GlobalAutoCRLF.SelectedItem as string);
            }

            if (OpenSSH.Checked)
                GitCommands.GitCommands.UnSetSsh();

            if (Putty.Checked)
                GitCommands.GitCommands.SetSsh(PlinkPath.Text);

            if (Other.Checked)
                GitCommands.GitCommands.SetSsh(OtherSsh.Text);

            GitCommands.Settings.SaveSettings();

            return true;
        }
Beispiel #9
0
        private void execute()
        {
            lock (revisions)
            {
                revisions.Clear();
            }

            heads = GitCommands.GetHeads(true);

            string formatString =
                /* <COMMIT>       */ COMMIT_BEGIN + "%n" +
                /* Hash           */ "%H%n" +
                /* Parents        */ "%P%n";
            if (!ShaOnly)
            {
                formatString +=
                    /* Tree           */ "%T%n" +
                    /* Author Name    */ "%aN%n" +
                    /* Author Date    */ "%ai%n" +
                    /* Committer Name */ "%cN%n" +
                    /* Committer Date */ "%ci%n" +
                    /* Commit Message */ "%s";
            }

            // NOTE:
            // when called from FileHistory and FollowRenamesInFileHistory is enabled the "--name-only" argument is set.
            // the filename is the next line after the commit-format defined above.

            if (Settings.OrderRevisionByDate)
            {
                LogParam = " --date-order " + LogParam;
            }
            else
            {
                LogParam = " --topo-order " + LogParam;
            }

            string arguments = String.Format(CultureInfo.InvariantCulture,
                "log -z {2} --pretty=format:\"{1}\" {0}",
                LogParam,
                formatString,
                BranchFilter);

            gitGetGraphCommand = new GitCommands();
            gitGetGraphCommand.StreamOutput = true;
            gitGetGraphCommand.CollectOutput = false;
            Process p = gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

            string line;
            do
            {
                line = p.StandardOutput.ReadLine();

                if (line != null)
                {
                    foreach (string entry in line.Split('\0'))
                    {
                        dataReceived(entry);
                    }
                }
            } while (line != null);
            finishRevision();

            Exited(this, new EventArgs());
        }
Beispiel #10
0
        private void LoadRevisions()
        {
            if (RevisionList == null)
            {
                return;
            }

            if (RevisionList != null && (RevisionList.Count == 0 && string.IsNullOrEmpty(Filter)))
            {
                Loading.Visible = false;
                NoCommits.Visible = true;
                Revisions.Visible = false;
                return;
            }

            Revisions.SuspendLayout();
            Revisions.Columns[3].HeaderText = Settings.ShowAuthorDate ? "Author Date" : "Commit Date";

            if (!ScrollBarSet)
            {
                ScrollBarSet = true;
                Revisions.ScrollBars = ScrollBars.None;
                Revisions.RowCount = RevisionList.Count;
                Revisions.ScrollBars = ScrollBars.Vertical;

                if (RevisionList.Count >= GitCommands.Settings.MaxCommits)
                {
                    string grep = "";
                    if (!string.IsNullOrEmpty(Filter))
                        grep = " --grep=\"" + Filter + "\" ";

                    gitCountCommitsCommand = new GitCommands.GitCommands();
                    gitCountCommitsCommand.CmdStartProcess("cmd.exe", "/c \"\"" + Settings.GitCommand + "\" rev-list " + grep + LogParam + " | \"" + Settings.GitBinDir + "wc\" -l\"");
                    gitCountCommitsCommand.Exited += new EventHandler(gitCountCommitsCommand_Exited);
                }

            }

            Revisions.SelectionChanged -= new EventHandler(Revisions_SelectionChanged);

            if (LastScrollPos > 0 && Revisions.RowCount > LastScrollPos)
            {
                Revisions.FirstDisplayedScrollingRowIndex = LastScrollPos;
                LastScrollPos = -1;
            }

            if (LastSelectedRows.Count > 0)
            {
                Revisions.ClearSelection();

                if (Revisions.Rows.Count > LastSelectedRows[0])
                    Revisions.CurrentCell = Revisions.Rows[LastSelectedRows[0]].Cells[0];

                foreach (int row in LastSelectedRows)
                {
                    if (Revisions.Rows.Count > row)
                    {
                        Revisions.Rows[row].Selected = true;
                    }
                }
                LastSelectedRows.Clear();
            }

            DrawVisibleGraphPart();

            Loading.Visible = false;
            Revisions.Enabled = true;
            Revisions.Focus();
            Revisions.SelectionChanged += new EventHandler(Revisions_SelectionChanged);

            Revisions.ResumeLayout();

            if (initialLoad)
            {
                initialLoad = false;
                SelecctionTimer.Enabled = false;
                SelecctionTimer.Stop();
                SelecctionTimer.Enabled = true;
                SelecctionTimer.Start();
            }
        }
        private void InitMergetool()
        {
            Cursor.Current = Cursors.WaitCursor;
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            mergetool = GitCommands.GitCommands.GetSetting("merge.tool");
            if (string.IsNullOrEmpty(mergetool))
                mergetool = gitCommands.GetGlobalSetting("merge.tool");

            if (string.IsNullOrEmpty(mergetool))
            {
                MessageBox.Show(noMergeTool.Text);
                return;
            }

            mergetoolCmd = GitCommands.GitCommands.GetSetting("mergetool." + mergetool + ".cmd");
            if (string.IsNullOrEmpty(mergetoolCmd))
                mergetoolCmd = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".cmd");

            mergetoolPath = GitCommands.GitCommands.GetSetting("mergetool." + mergetool + ".path");
            if (string.IsNullOrEmpty(mergetoolPath))
                mergetoolPath = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".path");

            if (string.IsNullOrEmpty(mergetool) || mergetool == "kdiff3")
                mergetoolCmd = mergetoolPath + " \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"";

            mergetoolPath = mergetoolCmd.Substring(0, mergetoolCmd.IndexOf(".exe") + 5).Trim(new char[]{'\"', ' '});
            mergetoolCmd = mergetoolCmd.Substring(mergetoolCmd.IndexOf(".exe") + 5);
        }
Beispiel #12
0
        private void GlobalMergeTool_TextChanged(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            MergetoolPath.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".path");
            MergeToolCmd.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".cmd");

            button1_Click_1(null, null);
        }
Beispiel #13
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            if (GlobalMergeTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                MergeToolCmd.Text = "";

                string kdiff3path = gitCommands.GetGlobalSetting("mergetool.kdiff3.path");
                if (!kdiff3path.Contains("kdiff3.exe"))
                    kdiff3path = "";
                if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                {
                    kdiff3path = @"c:\Program Files\KDiff3\kdiff3.exe";
                    if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                    {
                        kdiff3path = @"c:\Program Files (x86)\KDiff3\kdiff3.exe";
                        if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                        {
                            kdiff3path = GetRegistryValue(Registry.LocalMachine, "SOFTWARE\\KDiff3", "") + "\\kdiff3.exe";
                            if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                            {
                                kdiff3path = MergetoolPath.Text;
                                if (!kdiff3path.Contains("kdiff3.exe"))
                                    kdiff3path = "";
                            }
                        }
                    }

                }
                MergetoolPath.Text = kdiff3path;
            }
            AutoConfigMergeToolcmd();
        }
Beispiel #14
0
        private void AutoConfigMergeToolcmd()
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            if (GlobalMergeTool.Text.Equals("p4merge", StringComparison.CurrentCultureIgnoreCase))
            {
                if (MergetoolPath.Text.Contains("kdiff3") || MergetoolPath.Text.Contains("TortoiseMerge"))
                    MergetoolPath.Text = "";
                if (string.IsNullOrEmpty(MergetoolPath.Text) || !File.Exists(MergetoolPath.Text))
                {
                    MergetoolPath.Text = @"c:\Program Files\Perforce\p4merge.exe";

                    MergetoolPath.Text = FindFileInFolders("p4merge.exe",
                                       @"c:\Program Files (x86)\Perforce\",
                                       @"c:\Program Files\Perforce\");

                    if (!File.Exists(MergetoolPath.Text))
                    {
                        MergetoolPath.Text = "";
                        MessageBox.Show("Please enter the path to p4merge.exe and press suggest.", "Suggest mergetool cmd");
                        return;
                    }
                }

                MergeToolCmd.Text = "\"" + MergetoolPath.Text + "\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"";
                return;
            }

            if (GlobalMergeTool.Text.Equals("Araxis", StringComparison.CurrentCultureIgnoreCase))
            {
                if (MergetoolPath.Text.Contains("kdiff3") || MergetoolPath.Text.Contains("TortoiseMerge"))
                    MergetoolPath.Text = "";
                if (string.IsNullOrEmpty(MergetoolPath.Text) || !File.Exists(MergetoolPath.Text))
                {
                    MergetoolPath.Text = FindFileInFolders("Compare.exe",
                                                           @"C:\Program Files (x86)\Araxis\Araxis Merge\",
                                                           @"C:\Program Files\Araxis\Araxis Merge\");

                    if (!File.Exists(MergetoolPath.Text))
                    {
                        MergetoolPath.Text = "";
                        MessageBox.Show("Please enter the path to Compare.exe and press suggest.", "Suggest mergetool cmd");
                        return;
                    }
                }

                MergeToolCmd.Text = "\"" + MergetoolPath.Text + "\" -wait -merge -3 -a1 \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"";
                return;
            }

            if (GlobalMergeTool.Text.Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase))
            {
                if (MergetoolPath.Text.Contains("kdiff3") || MergetoolPath.Text.Contains("p4merge"))
                    MergetoolPath.Text = "";
                if (string.IsNullOrEmpty(MergetoolPath.Text) || !File.Exists(MergetoolPath.Text))
                {
                    MergetoolPath.Text = FindFileInFolders("TortoiseMerge.exe",
                                       @"c:\Program Files (x86)\TortoiseSVN\bin\",
                                       @"c:\Program Files\TortoiseSVN\bin\",
                                       @"c:\Program Files (x86)\TortoiseGit\bin\",
                                       @"c:\Program Files\TortoiseGit\bin\");

                    if (!File.Exists(MergetoolPath.Text))
                    {
                        MergetoolPath.Text = "";
                        MessageBox.Show("Please enter the path to TortoiseMerge.exe and press suggest.", "Suggest mergetool cmd");
                        return;
                    }
                }

                MergeToolCmd.Text = "\"TortoiseMerge.exe\" /base:\"$BASE\" /mine:\"$LOCAL\" /theirs:\"$REMOTE\" /merged:\"$MERGED\"";
                return;
            }

            if (GlobalMergeTool.Text.Equals("DiffMerge", StringComparison.CurrentCultureIgnoreCase))
            {
                if (MergetoolPath.Text.Contains("kdiff3") || MergetoolPath.Text.Contains("p4merge"))
                    MergetoolPath.Text = "";
                if (string.IsNullOrEmpty(MergetoolPath.Text) || !File.Exists(MergetoolPath.Text))
                {
                    MergetoolPath.Text = FindFileInFolders("DiffMerge.exe",
                                       @"C:\Program Files (x86)\SourceGear\DiffMerge\",
                                       @"C:\Program Files\SourceGear\DiffMerge\");

                    if (!File.Exists(MergetoolPath.Text))
                    {
                        MergetoolPath.Text = "";
                        MessageBox.Show("Please enter the path to DiffMerge.exe and press suggest.", "Suggest mergetool cmd");
                        return;
                    }
                }

                ///m /r=%merged /t1=%yname /t2=%bname /t3=%tname /c=%mname %mine %base %theirs
                MergeToolCmd.Text = "\"" + MergetoolPath.Text + "\" /m /r=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"";
                return;
            }
        }
Beispiel #15
0
        private bool CheckMergeTool()
        {
            DiffTool.Visible = true;
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool")))
            {
                DiffTool.BackColor = Color.LightSalmon;
                DiffTool.Text = "You need to configure merge tool in order to solve mergeconflicts (kdiff3 for example).";
                return false;
            }

            if (Settings.RunningOnWindows())
            {
                if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
                {
                    string p = gitCommands.GetGlobalSetting("mergetool.kdiff3.path");
                    if (string.IsNullOrEmpty(p) || !File.Exists(p))
                    {
                        DiffTool.BackColor = Color.LightSalmon;
                        DiffTool.Text = "KDiff3 is configured as mergetool, but the path to kdiff.exe is not configured.";
                        return false;
                    }
                    DiffTool.BackColor = Color.LightGreen;
                    DiffTool.Text = "KDiff3 is configured as mergetool.";
                    return true;
                }
                string mergetool = gitCommands.GetGlobalSetting("merge.tool");
                if (mergetool.Equals("p4merge", StringComparison.CurrentCultureIgnoreCase) ||
                    mergetool.Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase))
                {
                    string p = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".cmd");
                    if (string.IsNullOrEmpty(p))
                    {
                        DiffTool.BackColor = Color.LightSalmon;
                        DiffTool.Text = mergetool + " is configured as mergetool, this is a custom mergetool and needs a custom cmd to be configured.";
                        return false;
                    }
                    DiffTool.BackColor = Color.LightGreen;
                    DiffTool.Text = "There is a custom mergetool configured: " + mergetool;
                    return true;
                }
            }
            DiffTool.BackColor = Color.LightGreen;
            DiffTool.Text = "There is a mergetool configured.";
            return true;
        }
Beispiel #16
0
        private void DiffToolCmdSuggest_Click(object sender, EventArgs e)
        {
            if (!Settings.RunningOnWindows())
                return;

            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            if (GlobalDiffTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                string kdiff3path = gitCommands.GetGlobalSetting("difftool.kdiff3.path");
                string regkdiff3path = GetRegistryValue(Registry.LocalMachine, "SOFTWARE\\KDiff3", "") + "\\kdiff3.exe";

                DifftoolPath.Text = FindFileInFolders("kdiff3.exe", kdiff3path,
                                                                    @"c:\Program Files\KDiff3\",
                                                                    @"c:\Program Files (x86)\KDiff3\",
                                                                    regkdiff3path);
            }
            if (GlobalDiffTool.Text.Equals("winmerge", StringComparison.CurrentCultureIgnoreCase))
            {
                string winmergepath = gitCommands.GetGlobalSetting("difftool.winmerge.path");

                DifftoolPath.Text = FindFileInFolders("winmergeu.exe", winmergepath,
                                                                    @"c:\Program Files\winmerge\",
                                                                    @"c:\Program Files (x86)\winmerge\");
            }
            if (File.Exists(DifftoolPath.Text))
                DifftoolCmd.Text = "\"" + DifftoolPath.Text + "\" \"$LOCAL\" \"$REMOTE\"";
        }
Beispiel #17
0
        private void execute()
        {
            lock (revisions)
            {
                revisions.Clear();
            }

            heads = GitCommands.GetHeads(true);

            string formatString =
                /* <COMMIT>       */ COMMIT_BEGIN + "%n" +
                /* Hash           */ "%H%n" +
                /* Parents        */ "%P%n";
            if (!ShaOnly)
            {
                formatString +=
                    /* Tree           */ "%T%n" +
                    /* Author Name    */ "%aN%n" +
                    /* Author Date    */ "%ai%n" +
                    /* Committer Name */ "%cN%n" +
                    /* Committer Date */ "%ci%n" +
                    /* Commit Message */ "%s";
            }

            if (Settings.OrderRevisionByDate)
            {
                LogParam = " --date-order " + LogParam;
            }
            else
            {
                LogParam = " --topo-order " + LogParam;
            }

            string arguments = String.Format(CultureInfo.InvariantCulture,
                "log {2} --pretty=format:\"{1}\" {0}",
                LogParam,
                formatString,
                BranchFilter);

            gitGetGraphCommand = new GitCommands();
            gitGetGraphCommand.StreamOutput = true;
            gitGetGraphCommand.CollectOutput = false;
            Process p = gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

            string line;
            do
            {
                line = p.StandardOutput.ReadLine();
                dataReceived(line);
            } while (line != null);

            Exited(this, new EventArgs());
        }
Beispiel #18
0
        private void ExternalDiffTool_TextChanged(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            DifftoolPath.Text = gitCommands.GetGlobalSetting("difftool." + GlobalDiffTool.Text.Trim() + ".path");

            ResolveDiffToolPath();
        }
Beispiel #19
0
        private void ResolveDiffToolPath()
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            if (GlobalDiffTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                string kdiff3path = gitCommands.GetGlobalSetting("difftool.kdiff3.path");
                if (!kdiff3path.Contains("kdiff3.exe"))
                    kdiff3path = "";
                if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                {
                    kdiff3path = @"c:\Program Files\KDiff3\kdiff3.exe";
                    if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                    {
                        kdiff3path = @"c:\Program Files (x86)\KDiff3\kdiff3.exe";
                        if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                        {
                            kdiff3path = GetRegistryValue(Registry.LocalMachine, "SOFTWARE\\KDiff3", "") + "\\kdiff3.exe";
                            if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                            {
                                kdiff3path = MergetoolPath.Text;
                                if (!kdiff3path.Contains("kdiff3.exe"))
                                    kdiff3path = "";
                            }
                        }
                    }

                }
                DifftoolPath.Text = kdiff3path;
            }
        }
Beispiel #20
0
        private void GlobalMergeTool_TextChanged(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
            MergetoolPath.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".path");
            MergeToolCmd.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".cmd");

            if (GlobalMergeTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase) && string.IsNullOrEmpty(MergeToolCmd.Text))
                MergeToolCmd.Enabled = false;
            else
                MergeToolCmd.Enabled = true;

            button1_Click_1(null, null);
        }
Beispiel #21
0
        public static bool SolveKDiffPath(GitCommands.GitCommands gitCommands)
        {
            string kdiff3path = gitCommands.GetGlobalSetting("mergetool.kdiff3.path");
            if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
            {
                kdiff3path = @"c:\Program Files\KDiff3\kdiff3.exe";
                if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                {
                    kdiff3path = @"c:\Program Files (x86)\KDiff3\kdiff3.exe";
                    if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                    {
                        kdiff3path = GetRegistryValue(Registry.LocalMachine, "SOFTWARE\\KDiff3", "") + "\\kdiff3.exe";
                        if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path))
                        {
                            kdiff3path = "";
                            return false;
                        }
                    }
                }
            }
            gitCommands.SetGlobalSetting("mergetool.kdiff3.path", kdiff3path);

            return true;
        }
Beispiel #22
0
 private bool CheckGlobalUserSettingsValid()
 {
     UserNameSet.Visible = true;
     GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
     if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.name")) ||
         string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.email")))
     {
         UserNameSet.BackColor = Color.LightSalmon;
         UserNameSet.Text = "You need to configure a user name and an email address.";
         return false;
     }
     UserNameSet.BackColor = Color.LightGreen;
     UserNameSet.Text = "There is a user name and an email address configured.";
     return true;
 }
Beispiel #23
0
        public bool CheckSettings()
        {
            bool bValid = true;
            try
            {
                if (string.IsNullOrEmpty(GitCommands.Settings.GetInstallDir()))
                {
                    GitExtensionsInstall.BackColor = Color.LightSalmon;
                    GitExtensionsInstall.Text = "Registry entry missing [Software\\GitExtensions\\GitExtensions\\1.0.0.0\\InstallDir].";
                    bValid = false;
                }
                else
                {
                    GitExtensionsInstall.BackColor = Color.LightGreen;
                    GitExtensionsInstall.Text = "GitExtensions is properly registered.";
                }

                if (string.IsNullOrEmpty(GetRegistryValue(Registry.LocalMachine, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", "{3C16B20A-BA16-4156-916F-0A375ECFFE24}")) ||
                    string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "*\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) ||
                    string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) ||
                    string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\Background\\shellex\\ContextMenuHandlers\\GitExtensions2", null)))
                {
                    ShellExtensionsRegistered.BackColor = Color.LightSalmon;
                    ShellExtensionsRegistered.Text = "GitExtensionsShellEx.dll needs to be registered in order to use the shell extensions.";
                    bValid = false;
                }
                else
                {
                    ShellExtensionsRegistered.BackColor = Color.LightGreen;
                    ShellExtensionsRegistered.Text = "Shell extensions registered properly.";
                }

                GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();
                if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.name")) ||
                    string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.email")))
                {
                    UserNameSet.BackColor = Color.LightSalmon;
                    UserNameSet.Text = "You need to configure a user name and an email address.";
                    bValid = false;
                }
                else
                {
                    UserNameSet.BackColor = Color.LightGreen;
                    UserNameSet.Text = "There is a user name and an email address configured.";
                }

                if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool")))
                {
                    DiffTool.BackColor = Color.LightSalmon;
                    DiffTool.Text = "You need to configure merge tool in order to solve mergeconflicts (kdiff3 for example).";
                    bValid = false;
                }
                else
                {
                    if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string p = gitCommands.GetGlobalSetting("mergetool.kdiff3.path");
                        if (string.IsNullOrEmpty(p) || !File.Exists(p))
                        {
                            DiffTool.BackColor = Color.LightSalmon;
                            DiffTool.Text = "KDiff3 is configured as mergetool, but the path to kdiff.exe is not configured.";
                            bValid = false;
                        }
                        else
                        {
                            DiffTool.BackColor = Color.LightGreen;
                            DiffTool.Text = "KDiff3 is configured as mergetool.";
                        }
                    }
                    else
                    {
                        string mergetool = gitCommands.GetGlobalSetting("merge.tool");
                        if (mergetool.Equals("p4merge", StringComparison.CurrentCultureIgnoreCase) ||
                            mergetool.Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase))
                        {
                            string p = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".cmd");
                            if (string.IsNullOrEmpty(p))
                            {
                                DiffTool.BackColor = Color.LightSalmon;
                                DiffTool.Text = mergetool + " is configured as mergetool, this is a custom mergetool and needs a custom cmd to be configured.";
                                bValid = false;
                            }
                            else
                            {
                                DiffTool.BackColor = Color.LightGreen;
                                DiffTool.Text = "There is a custom mergetool configured: " + mergetool;
                            }
                        }
                        else
                        {
                            DiffTool.BackColor = Color.LightGreen;
                            DiffTool.Text = "There is a mergetool configured.";
                        }
                    }
                }

                if (!CanFindGitCmd())
                {
                    GitFound.BackColor = Color.LightSalmon;
                    GitFound.Text = "git.cmd not found. To solve this problem you can set the correct path in settings.";
                    bValid = false;
                }
                else
                {
                    GitFound.BackColor = Color.LightGreen;
                    GitFound.Text = "git.cmd is found on your computer.";
                }

                if (string.IsNullOrEmpty(GitCommands.GitCommands.RunCmd(GitCommands.Settings.GitBinDir + "git.exe", "")))
                {
                    GitBinFound.BackColor = Color.LightSalmon;
                    GitBinFound.Text = "git.exe not found. To solve this problem you can set the correct path in settings.";
                    bValid = false;
                }
                else
                {
                    GitBinFound.BackColor = Color.LightGreen;
                    GitBinFound.Text = "git.exe is found on your computer.";
                }
                if (GitCommands.GitCommands.Plink())
                {
                    if (!File.Exists(GitCommands.Settings.Plink) || !File.Exists(GitCommands.Settings.Puttygen) || !File.Exists(GitCommands.Settings.Pageant))
                    {
                        SshConfig.BackColor = Color.LightSalmon;
                        SshConfig.Text = "PuTTY is configured as SSH client but cannot find plink.exe, puttygen.exe or pageant.exe.";
                        bValid = false;
                    }
                    else
                    {
                        SshConfig.BackColor = Color.LightGreen;
                        SshConfig.Text = "SSH client PuTTY is configured properly";
                    }
                }
                else
                {
                    SshConfig.BackColor = Color.LightGreen;
                    if (string.IsNullOrEmpty(GitCommands.GitCommands.GetSsh()))
                        SshConfig.Text = "Default SSH client, OpenSSH, will be used. (commandline window will appear on pull, push and clone operations)";
                    else
                        SshConfig.Text = "Unknown SSH client configured: " + GitCommands.GitCommands.GetSsh();
                }

            }
            catch
            {
            }

            if ((Application.UserAppDataRegistry.GetValue("checksettings") == null ||
                  Application.UserAppDataRegistry.GetValue("checksettings").ToString() == "true"))
            {
                CheckAtStartup.Checked = true;
            }
            else
            {
                CheckAtStartup.Checked = false;
            }

            if (bValid && CheckAtStartup.Checked)
            {
                Application.UserAppDataRegistry.SetValue("checksettings", false);
                CheckAtStartup.Checked = false;
            }

            return bValid;
        }
        private void InitMergetool()
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            mergetool = GitCommands.GitCommands.GetSetting("merge.tool");
            if (string.IsNullOrEmpty(mergetool))
                mergetool = gitCommands.GetGlobalSetting("merge.tool");

            if (string.IsNullOrEmpty(mergetool))
            {
                MessageBox.Show("There is no mergetool configured. Please go to settings and set a mergetool!");
                return;
            }

            mergetoolCmd = GitCommands.GitCommands.GetSetting("mergetool." + mergetool + ".cmd");
            if (string.IsNullOrEmpty(mergetoolCmd))
                mergetoolCmd = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".cmd");

            mergetoolPath = GitCommands.GitCommands.GetSetting("mergetool." + mergetool + ".path");
            if (string.IsNullOrEmpty(mergetoolPath))
                mergetoolPath = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".path");

            if (string.IsNullOrEmpty(mergetool) || mergetool == "kdiff3")
                mergetoolCmd = mergetoolPath + " \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"";

            mergetoolPath = mergetoolCmd.Substring(0, mergetoolCmd.IndexOf(".exe") + 5).Trim(new char[]{'\"', ' '});
            mergetoolCmd = mergetoolCmd.Substring(mergetoolCmd.IndexOf(".exe") + 5);
        }
Beispiel #25
0
        private void BrowseMergeTool_Click(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            if (GlobalMergeTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                MergetoolPath.Text = SelectFile(".", "kdiff3.exe (kdiff3.exe)|kdiff3.exe", MergetoolPath.Text);
            }
            else
                if (GlobalMergeTool.Text.Equals("p4merge", StringComparison.CurrentCultureIgnoreCase))
                    MergetoolPath.Text = SelectFile(".", "p4merge.exe (p4merge.exe)|p4merge.exe", MergetoolPath.Text);
                else
                    if (GlobalMergeTool.Text.Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase))
                        MergetoolPath.Text = SelectFile(".", "TortoiseMerge.exe (TortoiseMerge.exe)|TortoiseMerge.exe", MergetoolPath.Text);
                    else
                        MergetoolPath.Text = SelectFile(".", "*.exe (*.exe)|*.exe", MergetoolPath.Text);
        }
Beispiel #26
0
        public static string StageFiles(IList<GitItemStatus> files)
        {
            GitCommands gitCommand = new GitCommands();

            string output = "";

            Process process1 = null;
            foreach (GitItemStatus file in files)
            {
                if (!file.IsDeleted)
                {
                    if (process1 == null)
                        process1 = gitCommand.CmdStartProcess(Settings.GitCommand, "update-index --add --stdin");

                    process1.StandardInput.WriteLine("\"" + FixPath(file.Name) + "\"");
                }
            }
            if (process1 != null)
            {
                process1.StandardInput.Close();
                process1.WaitForExit();

                if (gitCommand.Output != null)
                    output = gitCommand.Output.ToString().Trim();
            }

            Process process2 = null;
            foreach (GitItemStatus file in files)
            {
                if (file.IsDeleted)
                {
                    if (process2 == null)
                        process2 = gitCommand.CmdStartProcess(Settings.GitCommand, "update-index --remove --stdin");
                    process2.StandardInput.WriteLine("\"" + FixPath(file.Name) + "\"");
                }
            }
            if (process2 != null)
            {
                process2.StandardInput.Close();
                process2.WaitForExit();

                if (gitCommand.Output != null)
                {
                    if (!string.IsNullOrEmpty(output))
                    {
                        output += Environment.NewLine;
                    }
                    output += gitCommand.Output.ToString().Trim();
                }
            }

            return output;
        }
Beispiel #27
0
        private void DiffTool_Click(object sender, EventArgs e)
        {
            GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

            if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool")))
            {
                if (MessageBox.Show("There is no mergetool configured. Do you want to configure kdiff3 as your mergetool?" + Environment.NewLine + "Select no if you want to configure a different mergetool yourself.", "Mergetool", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    SolveKDiff();
                    GlobalMergeTool.Text = "kdiff3";
                }
                else
                {
                    tabControl1.SelectTab("GlobalSettingsPage");
                    return;
                }
            }

            if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                SolveKDiffPath(gitCommands);
            }
            else
                if (gitCommands.GetGlobalSetting("merge.tool").Equals("p4merge", StringComparison.CurrentCultureIgnoreCase) ||
                    gitCommands.GetGlobalSetting("merge.tool").Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase))
                {
                    AutoConfigMergeToolcmd();
                    gitCommands.SetGlobalSetting("mergetool." + gitCommands.GetGlobalSetting("merge.tool") + ".cmd", MergeToolCmd.Text);
                }

            if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase) && string.IsNullOrEmpty(gitCommands.GetGlobalSetting("mergetool.kdiff3.path")))
            {
                MessageBox.Show("Path to kdiff3 could not be found automatically." + Environment.NewLine + "Please make sure KDiff3 is installed or set path manually.");
                tabControl1.SelectTab("GlobalSettingsPage");
                return;
            }

            Rescan_Click(null, null);
        }
Beispiel #28
0
        public static string UnstageFiles(List<GitItemStatus> files)
        {
            GitCommands gitCommand = new GitCommands();

            string output = "";

            Process process1 = null;
            foreach (GitItemStatus file in files)
            {
                if (!file.IsNew)
                {
                    if (process1 == null)
                        process1 = gitCommand.CmdStartProcess(Settings.GitCommand, "update-index --info-only --index-info");

                    process1.StandardInput.WriteLine("0 0000000000000000000000000000000000000000\t\"" + FixPath(file.Name) + "\"");
                }
            }
            if (process1 != null)
            {
                process1.StandardInput.Close();
                process1.WaitForExit();
            }

            if (gitCommand.Output != null)
                output = gitCommand.Output.ToString();

            Process process2 = null;
            foreach (GitItemStatus file in files)
            {
                if (file.IsNew)
                {
                    if (process2 == null)
                        process2 = gitCommand.CmdStartProcess(Settings.GitCommand, "update-index --force-remove --stdin");
                    process2.StandardInput.WriteLine("\"" + FixPath(file.Name) + "\"");
                }
            }
            if (process2 != null)
            {
                process2.StandardInput.Close();
                process2.WaitForExit();
            }

            if (gitCommand.Output != null)
                output += gitCommand.Output.ToString();

            return output;
        }
Beispiel #29
0
        private void LoadSettings()
        {
            try
            {
                if (GitCommands.Settings.Encoding.GetType() == typeof(ASCIIEncoding))
                    Encoding.Text = "ASCII";
                else
                    if (GitCommands.Settings.Encoding.GetType() == typeof(UnicodeEncoding))
                        Encoding.Text = "Unicode";
                    else
                        if (GitCommands.Settings.Encoding.GetType() == typeof(UTF7Encoding))
                            Encoding.Text = "UTF7";
                        else
                            if (GitCommands.Settings.Encoding.GetType() == typeof(UTF8Encoding))
                                Encoding.Text = "UTF8";
                            else
                                if (GitCommands.Settings.Encoding.GetType() == typeof(UTF32Encoding))
                                    Encoding.Text = "UTF32";
                                else
                                    if (GitCommands.Settings.Encoding == System.Text.Encoding.Default)
                                        Encoding.Text = "Default";

                FollowRenamesInFileHistory.Checked = Settings.FollowRenamesInFileHistory;

                RevisionGraphColorLabel.BackColor = Settings.RevisionGraphColor;
                RevisionGraphColorLabel.Text = Settings.RevisionGraphColor.Name;
                RevisionGraphColorLabel.ForeColor = ColorHelper.GetForeColorForBackColor(RevisionGraphColorLabel.BackColor);
                RevisionGraphColorSelected.BackColor = Settings.RevisionGraphColorSelected;
                RevisionGraphColorSelected.Text = Settings.RevisionGraphColorSelected.Name;
                RevisionGraphColorSelected.ForeColor = ColorHelper.GetForeColorForBackColor(RevisionGraphColorSelected.BackColor);
                ColorTagLabel.BackColor = Settings.TagColor;
                ColorTagLabel.Text = Settings.TagColor.Name;
                ColorTagLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorTagLabel.BackColor);
                ColorBranchLabel.BackColor = Settings.BranchColor;
                ColorBranchLabel.Text = Settings.BranchColor.Name;
                ColorBranchLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorBranchLabel.BackColor);
                ColorRemoteBranchLabel.BackColor = Settings.RemoteBranchColor;
                ColorRemoteBranchLabel.Text = Settings.RemoteBranchColor.Name;
                ColorRemoteBranchLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorRemoteBranchLabel.BackColor);
                ColorOtherLabel.BackColor = Settings.OtherTagColor;
                ColorOtherLabel.Text = Settings.OtherTagColor.Name;
                ColorOtherLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorOtherLabel.BackColor);

                ColorAddedLineLabel.BackColor = Settings.DiffAddedColor;
                ColorAddedLineLabel.Text = Settings.DiffAddedColor.Name;
                ColorAddedLineLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorAddedLineLabel.BackColor);
                ColorRemovedLine.BackColor = Settings.DiffRemovedColor;
                ColorRemovedLine.Text = Settings.DiffRemovedColor.Name;
                ColorRemovedLine.ForeColor = ColorHelper.GetForeColorForBackColor(ColorRemovedLine.BackColor);
                ColorSectionLabel.BackColor = Settings.DiffSectionColor;
                ColorSectionLabel.Text = Settings.DiffSectionColor.Name;
                ColorSectionLabel.ForeColor = ColorHelper.GetForeColorForBackColor(ColorSectionLabel.BackColor);

                SmtpServer.Text = GitCommands.Settings.Smtp;

                MaxCommits.Value = GitCommands.Settings.MaxCommits;

                GitCommands.GitCommands gitCommands = new GitCommands.GitCommands();

                GitPath.Text = GitCommands.Settings.GitDir;
                GitBinPath.Text = GitCommands.Settings.GitBinDir;

                UserName.Text = GitCommands.GitCommands.GetSetting("user.name");
                UserEmail.Text = GitCommands.GitCommands.GetSetting("user.email");
                Editor.Text = GitCommands.GitCommands.GetSetting("core.editor");
                MergeTool.Text = GitCommands.GitCommands.GetSetting("merge.tool");

                Dictionary.Text = GitCommands.Settings.Dictionary;

                GlobalUserName.Text = gitCommands.GetGlobalSetting("user.name");
                GlobalUserEmail.Text = gitCommands.GetGlobalSetting("user.email");
                GlobalEditor.Text = gitCommands.GetGlobalSetting("core.editor");
                GlobalMergeTool.Text = gitCommands.GetGlobalSetting("merge.tool");

                SetCheckboxFromString(KeepMergeBackup, GitCommands.GitCommands.GetSetting("mergetool.keepBackup"));
                SetComboBoxFromString(LocalAutoCRLF, GitCommands.GitCommands.GetSetting("core.autocrlf"));

                if (!string.IsNullOrEmpty(GlobalMergeTool.Text))
                    MergetoolPath.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".path");
                if (!string.IsNullOrEmpty(GlobalMergeTool.Text))
                    MergeToolCmd.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".cmd");

                SetCheckboxFromString(GlobalKeepMergeBackup, gitCommands.GetGlobalSetting("mergetool.keepBackup"));
                SetComboBoxFromString(GlobalAutoCRLF, gitCommands.GetGlobalSetting("core.autocrlf"));

                PlinkPath.Text = GitCommands.Settings.Plink;
                PuttygenPath.Text = GitCommands.Settings.Puttygen;
                PageantPath.Text = GitCommands.Settings.Pageant;
                AutostartPageant.Checked = GitCommands.Settings.AutoStartPageant;

                CloseProcessDialog.Checked = GitCommands.Settings.CloseProcessDialog;
                ShowRevisionGraph.Checked = GitCommands.Settings.ShowRevisionGraph;
                ShowGitCommandLine.Checked = GitCommands.Settings.ShowGitCommandLine;

                UseFastChecks.Checked = GitCommands.Settings.UseFastChecks;
                ShowRelativeDate.Checked = GitCommands.Settings.RelativeDate;

                if (string.IsNullOrEmpty(GitCommands.GitCommands.GetSsh()))
                    OpenSSH.Checked = true;
                else
                    if (GitCommands.GitCommands.Plink())
                        Putty.Checked = true;
                    else
                    {
                        OtherSsh.Text = GitCommands.GitCommands.GetSsh();
                        Other.Checked = true;
                    }

                EnableSshOptions();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not load settigns.\n\n" + ex.Message);
            }
        }
Beispiel #30
0
        private void FormatPatch_Click(object sender, EventArgs e)
        {
            if (SaveToDir.Checked && string.IsNullOrEmpty(OutputPath.Text))
            {
                MessageBox.Show("You need to enter an output path.");
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(MailAddress.Text))
            {
                MessageBox.Show("You need to enter an email address.");
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(MailSubject.Text))
            {
                MessageBox.Show("You need to enter a mail subject.");
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(Settings.Smtp))
            {
                MessageBox.Show("You need to enter a valid stmp in the settings dialog.");
                return;
            }

            string savePatchesToDir = OutputPath.Text;

            if (!SaveToDir.Checked)
            {
                savePatchesToDir = Settings.WorkingDirGitDir() + "\\PatchesToMail";
                if (Directory.Exists(savePatchesToDir))
                {
                    foreach (string file in Directory.GetFiles(savePatchesToDir, "*.patch"))
                        File.Delete(file);
                }
                else
                {
                    Directory.CreateDirectory(savePatchesToDir);
                }
            }

            string rev1 = "";
            string rev2 = "";
            string result = "";

            if (RevisionGrid.GetRevisions().Count > 0)
            {
                if (RevisionGrid.GetRevisions().Count == 1)
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[0].Guid;
                    result = new GitCommands.GitCommands().FormatPatch(rev1, rev2, savePatchesToDir);
                }

                if (RevisionGrid.GetRevisions().Count == 2)
                {
                    rev1 = RevisionGrid.GetRevisions()[0].ParentGuids[0];
                    rev2 = RevisionGrid.GetRevisions()[1].Guid;
                    result = new GitCommands.GitCommands().FormatPatch(rev1, rev2, savePatchesToDir);
                }

                if (RevisionGrid.GetRevisions().Count > 2)
                {
                    int n = 0;
                    foreach (GitRevision revision in RevisionGrid.GetRevisions())
                    {
                        n++;
                        rev1 = revision.ParentGuids[0];
                        rev2 = revision.Guid;
                        result += new GitCommands.GitCommands().FormatPatch(rev1, rev2, savePatchesToDir, n);
                    }
                }
            } else
            if (string.IsNullOrEmpty(rev1) || string.IsNullOrEmpty(rev2))
            {
                MessageBox.Show("You need to select 2 revisions", "Patch error");
                return;
            }

            if (!SaveToDir.Checked)
            {
                if (SendMail(savePatchesToDir))
                    result += "\n\nSend to: " + MailAddress.Text;
                else
                    result += "\n\nFailed to send mail.";

                //Clean up
                if (Directory.Exists(savePatchesToDir))
                {
                    foreach (string file in Directory.GetFiles(savePatchesToDir, "*.patch"))
                        File.Delete(file);
                }
            }

            MessageBox.Show(result, "Patch result");
            Close();
        }