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.
21 #include "UnIgnoreCommand.h"
23 #include "MessageBox.h"
24 #include "PathUtils.h"
25 #include "SVNProperties.h"
27 bool UnIgnoreCommand::Execute()
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);
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();
50 value
= value
.Trim("\n\r");
53 value
.Replace("\n\n", "\n");
55 // Delete all occurrences of 'name'
56 // "\n" is temporarily prepended to make the algorithm easier
58 value
.Replace("\n" + CUnicodeUtils::GetUTF8(name
) + "\n", "\n");
61 CStringA sTrimmedvalue
= value
;
63 if (sTrimmedvalue
.IsEmpty())
65 if (!props
.Remove(L
"svn:ignore"))
68 temp
.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY
, (LPCTSTR
)name
);
69 CMessageBox::Show(hwndExplorer
, temp
, L
"TortoiseGit", MB_ICONERROR
);
76 if (!props
.Add(L
"svn:ignore", (LPCSTR
)value
))
79 temp
.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY
, (LPCTSTR
)name
);
80 CMessageBox::Show(hwndExplorer
, temp
, L
"TortoiseGit", MB_ICONERROR
);
89 temp
.Format(IDS_PROC_UNIGNORESUCCESS
, (LPCTSTR
)filelist
);
90 CMessageBox::Show(hwndExplorer
, temp
, L
"TortoiseGit", MB_ICONINFORMATION
);