Pass HWND to CGitDiff
[TortoiseGit.git] / src / TortoiseProc / Commands / UnIgnoreCommand.cpp
blobd02be29c046025b028b47dce2c5b5de6e132cb11
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "UnIgnoreCommand.h"
23 #include "MessageBox.h"
24 #include "PathUtils.h"
25 #include "SVNProperties.h"
27 bool UnIgnoreCommand::Execute()
29 CString filelist;
30 BOOL err = FALSE;
31 for (int nPath = 0; nPath < pathList.GetCount(); ++nPath)
33 CString name = CPathUtils::PathPatternEscape(pathList[nPath].GetFileOrDirectoryName());
34 if (parser.HasKey(L"onlymask"))
35 name = L'*' + pathList[nPath].GetFileExtension();
36 filelist += name + L'\n';
37 CTSVNPath parentfolder = pathList[nPath].GetContainingDirectory();
38 SVNProperties props(parentfolder, SVNRev::REV_WC, false);
39 CStringA value;
40 for (int i = 0; i < props.GetCount(); ++i)
42 CString propname(props.GetItemName(i).c_str());
43 if (propname.CompareNoCase(L"svn:ignore") == 0)
45 //treat values as normal text even if they're not
46 value = (char *)props.GetItemValue(i).c_str();
47 break;
50 value = value.Trim("\n\r");
51 value += '\n';
52 value.Remove('\r');
53 value.Replace("\n\n", "\n");
55 // Delete all occurrences of 'name'
56 // "\n" is temporarily prepended to make the algorithm easier
57 value = "\n" + value;
58 value.Replace("\n" + CUnicodeUtils::GetUTF8(name) + "\n", "\n");
59 value = value.Mid(1);
61 CStringA sTrimmedvalue = value;
62 sTrimmedvalue.Trim();
63 if (sTrimmedvalue.IsEmpty())
65 if (!props.Remove(L"svn:ignore"))
67 CString temp;
68 temp.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY, (LPCTSTR)name);
69 CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONERROR);
70 err = TRUE;
71 break;
74 else
76 if (!props.Add(L"svn:ignore", (LPCSTR)value))
78 CString temp;
79 temp.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY, (LPCTSTR)name);
80 CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONERROR);
81 err = TRUE;
82 break;
86 if (err == FALSE)
88 CString temp;
89 temp.Format(IDS_PROC_UNIGNORESUCCESS, (LPCTSTR)filelist);
90 CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONINFORMATION);
91 return true;
93 return false;