From bbf8e656f799b342dba20aedb2486897ed338e6c Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 20 Jun 2012 16:07:51 +0200 Subject: [PATCH] Fixed issue #1228: Ignore by mask work recursively Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/Resources/TortoiseProcENG.rc | 30 +++++++++ src/TortoiseProc/AppUtils.cpp | 117 +++++++++++++++++++++++------------ src/TortoiseProc/AppUtils.h | 3 +- src/TortoiseProc/IgnoreDlg.cpp | 77 +++++++++++++++++++++++ src/TortoiseProc/IgnoreDlg.h | 45 ++++++++++++++ src/TortoiseProc/TortoiseProc.vcproj | 8 +++ src/TortoiseProc/resource.h | 10 ++- 8 files changed, 248 insertions(+), 43 deletions(-) create mode 100644 src/TortoiseProc/IgnoreDlg.cpp create mode 100644 src/TortoiseProc/IgnoreDlg.h diff --git a/src/Changelog.txt b/src/Changelog.txt index fcde12073..3392490ba 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -7,6 +7,7 @@ Released: unreleased * Optimized TGitCache overlay calculation (deleted but kept files are now displayed as such) * Fixed issue #1067: Add clear button into "stash list" * Fixed issue #1230: Filter/Search for Branches in Reference Browser + * Fixed issue #1228: Ignore by mask work recursively == Bug Fix == * Fixed issue #1213: cannot diff renamed files with Revision Diff Dialog diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 22314abb1..72dfb5b66 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -1567,6 +1567,28 @@ BEGIN EDITTEXT IDC_TOSUBJECT,52,96,234,12,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER END +IDD_IGNORE DIALOGEX 0, 0, 261, 151 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Ignore" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Ignore Type",IDC_GROUP_IGNORE_TYPE,7,7,247,46 + CONTROL "Ignore item(s) only in the containing folder(s)",IDC_RADIO_IGNORETYPE_ONLYINFOLDER, + "Button",BS_AUTORADIOBUTTON | WS_GROUP,15,21,231,10 + CONTROL "Ignore item(s) recursively",IDC_RADIO_IGNORETYPE_RECURSIVELY, + "Button",BS_AUTORADIOBUTTON,15,34,231,10 + GROUPBOX "Ignore File",IDC_GROUP_IGNORE_FILE,7,62,247,60 + CONTROL ".gitignore in the repository root",IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE, + "Button",BS_AUTORADIOBUTTON | WS_GROUP,15,75,231,10 + CONTROL ".gitignore in the containing directories of the items",IDC_RADIO_IGNOREFILE_LOCALGITIGNORES, + "Button",BS_AUTORADIOBUTTON,15,89,231,10 + CONTROL ".git/info/exclude",IDC_RADIO_IGNOREFILE_GITINFOEXCLUDE, + "Button",BS_AUTORADIOBUTTON,15,103,231,10 + DEFPUSHBUTTON "OK",IDOK,95,130,50,14 + PUSHBUTTON "Cancel",IDCANCEL,149,130,50,14 + PUSHBUTTON "Help",IDHELP,204,130,50,14,WS_DISABLED +END + ///////////////////////////////////////////////////////////////////////////// // @@ -2307,6 +2329,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 114 END + + IDD_IGNORE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 254 + TOPMARGIN, 7 + BOTTOMMARGIN, 144 + END END #endif // APSTUDIO_INVOKED diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index b8ddae947..dd019e36e 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -58,6 +58,7 @@ #include "RebaseDlg.h" #include "PropKey.h" #include "StashSave.h" +#include "IgnoreDlg.h" #include "FormatMessageWrapper.h" #include "SmartHandle.h" @@ -1052,63 +1053,97 @@ bool CAppUtils::PerformSwitch(CString ref, bool bForce /* false */, CString sNew return FALSE; } -bool CAppUtils::IgnoreFile(CTGitPathList &path,bool IsMask) +bool CAppUtils::OpenIgnoreFile(CStdioFile &file, const CString& filename) { - CString ignorefile; - ignorefile=g_Git.m_CurrentDir+_T("\\"); - - if(IsMask) + if (!file.Open(filename, CFile::modeCreate | CFile::modeReadWrite | CFile::modeNoTruncate)) { - ignorefile+=path.GetCommonRoot().GetDirectory().GetWinPathString()+_T("\\.gitignore"); - - } - else - { - ignorefile += _T(".gitignore"); + CMessageBox::Show(NULL, filename + _T(" Open Failure"), _T("TortoiseGit"), MB_OK | MB_ICONERROR); + return false; } - CStdioFile file; - if(!file.Open(ignorefile,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate)) + if (file.GetLength() > 0) { - CMessageBox::Show(NULL,ignorefile+_T(" Open Failure"),_T("TortoiseGit"),MB_OK); - return FALSE; + file.Seek(file.GetLength() - 1, 0); + auto_buffer buf(1); + file.Read(buf, 1); + file.SeekToEnd(); + if (buf[0] != _T('\n')) + file.WriteString(_T("\n")); } + else + file.SeekToEnd(); - try + return true; +} + +bool CAppUtils::IgnoreFile(CTGitPathList &path,bool IsMask) +{ + CIgnoreDlg ignoreDlg; + if (ignoreDlg.DoModal() == IDOK) { - if (file.GetLength() > 0) + CString ignorefile; + ignorefile = g_Git.m_CurrentDir + _T("\\"); + + switch (ignoreDlg.m_IgnoreFile) { - file.Seek(file.GetLength() - 1, 0); - auto_buffer buf(1); - file.Read(buf, 1); - file.SeekToEnd(); - if (buf[0] != _T('\n')) - file.WriteString(_T("\n")); + case 0: + ignorefile += _T(".gitignore"); + break; + case 2: + ignorefile += _T(".git/info/exclude"); + break; } - else - file.SeekToEnd(); - for(int i=0;i + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// IgnoreDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "TortoiseProc.h" +#include "IgnoreDlg.h" + +// CIgnoreDlg dialog + +IMPLEMENT_DYNAMIC(CIgnoreDlg, CStandAloneDialog) + +CIgnoreDlg::CIgnoreDlg(CWnd* pParent /*=NULL*/) + : CStandAloneDialog(CIgnoreDlg::IDD, pParent) + , m_IgnoreType(0) + , m_IgnoreFile(1) +{ + +} + +CIgnoreDlg::~CIgnoreDlg() +{ +} + +void CIgnoreDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CIgnoreDlg, CStandAloneDialog) +END_MESSAGE_MAP() + + +// CIgnoreDlg message handlers +BOOL CIgnoreDlg::OnInitDialog() +{ + CStandAloneDialog::OnInitDialog(); + + this->CheckRadioButton(IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE, IDC_RADIO_IGNOREFILE_GITINFOEXCLUDE, IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE + m_IgnoreType); + + AdjustControlSize(IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE); + AdjustControlSize(IDC_RADIO_IGNOREFILE_LOCALGITIGNORES); + AdjustControlSize(IDC_RADIO_IGNOREFILE_GITINFOEXCLUDE); + + this->CheckRadioButton(IDC_RADIO_IGNORETYPE_ONLYINFOLDER, IDC_RADIO_IGNORETYPE_RECURSIVELY, IDC_RADIO_IGNORETYPE_ONLYINFOLDER + m_IgnoreType); + + AdjustControlSize(IDC_RADIO_IGNORETYPE_ONLYINFOLDER); + AdjustControlSize(IDC_RADIO_IGNORETYPE_RECURSIVELY); + + return TRUE; +} + +void CIgnoreDlg::OnOK() +{ + m_IgnoreFile = this->GetCheckedRadioButton(IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE, IDC_RADIO_IGNOREFILE_GITINFOEXCLUDE) - IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE; + m_IgnoreType = this->GetCheckedRadioButton(IDC_RADIO_IGNORETYPE_ONLYINFOLDER, IDC_RADIO_IGNORETYPE_RECURSIVELY) - IDC_RADIO_IGNORETYPE_ONLYINFOLDER; + return CStandAloneDialog::OnOK(); +} diff --git a/src/TortoiseProc/IgnoreDlg.h b/src/TortoiseProc/IgnoreDlg.h new file mode 100644 index 000000000..45e9fb37d --- /dev/null +++ b/src/TortoiseProc/IgnoreDlg.h @@ -0,0 +1,45 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2012 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#pragma once + +#include "StandAloneDlg.h" +// CIgnoreDlg dialog + +class CIgnoreDlg : public CStandAloneDialog +{ + DECLARE_DYNAMIC(CIgnoreDlg) + +public: + CIgnoreDlg(CWnd* pParent = NULL); // standard constructor + virtual ~CIgnoreDlg(); + +// Dialog Data + enum { IDD = IDD_IGNORE }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnInitDialog(); + virtual void OnOK(); + + DECLARE_MESSAGE_MAP() + +public: + int m_IgnoreType; + int m_IgnoreFile; +}; diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index 3e7040c9f..4478ba937 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -2210,6 +2210,14 @@ > + + + + diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index cdc48279a..fb6d88d68 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -1127,6 +1127,13 @@ #define IDC_BUTTON_REVISION 1684 #define IDC_REPOBROWSER_URL 1685 #define IDC_REFLOG_BUTTONCLEARSTASH 1686 +#define IDC_GROUP_IGNORE_TYPE 1686 +#define IDC_RADIO_IGNORETYPE_ONLYINFOLDER 1687 +#define IDC_RADIO_IGNORETYPE_RECURSIVELY 1688 +#define IDC_RADIO_IGNOREFILE_GLOBALGITIGNORE 1689 +#define IDC_RADIO_IGNOREFILE_LOCALGITIGNORES 1690 +#define IDC_RADIO_IGNOREFILE_GITINFOEXCLUDE 1691 +#define IDC_GROUP_IGNORE_FILE 1692 #define IDS_ABOUTVERSION 1700 #define IDS_ABOUTVERSIONBOX 1701 #define IDS_DLGTITLE_ADD_DIFF_TOOL 1750 @@ -1399,6 +1406,7 @@ #define IDD_BISECTSTART 4574 #define IDD_STASH 4575 #define IDD_DIFFSUBMODULE 4576 +#define IDD_IGNORE 4577 #define IDC_COMBOBOXEX_LOCAL_BRANCH 5000 #define IDC_COMBOBOXEX_REMOTE_BRANCH 5001 #define IDC_COMBOBOXEX_BAD 5001 @@ -1503,7 +1511,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 343 #define _APS_NEXT_COMMAND_VALUE 32840 -#define _APS_NEXT_CONTROL_VALUE 1686 +#define _APS_NEXT_CONTROL_VALUE 1692 #define _APS_NEXT_SYMED_VALUE 201 #endif #endif -- 2.11.4.GIT