1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008,2011 - TortoiseSVN
4 // Copyright (C) 2008-2013 - TortoiseGit
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 "LogCommand.h"
22 #include "StringUtils.h"
25 bool LogCommand::Execute()
27 //the log command line looks like this:
28 //command:log path:<path_to_file_or_directory_to_show_the_log_messages> [startrev:<startrevision>] [endrev:<endrevision>]
32 CString revstart
= parser
.GetVal(_T("startrev"));
33 if (revstart
.IsEmpty())
35 // support deprecated parameter prior 1.5.0
36 revstart
= parser
.GetVal(_T("revstart"));
38 if (revstart
== GIT_REV_ZERO
)
40 if (!revstart
.IsEmpty())
41 range
.Format(_T("%s.."), g_Git
.FixBranchName(revstart
));
43 CString revend
= parser
.GetVal(_T("endrev"));
46 // support deprecated parameter prior 1.5.0
47 revend
= parser
.GetVal(_T("revend"));
49 if (revend
== GIT_REV_ZERO
)
51 if (!revend
.IsEmpty())
52 range
+= g_Git
.FixBranchName(revend
);
54 if (parser
.HasVal(_T("range")))
55 range
= parser
.GetVal(_T("range"));
57 CString val
= parser
.GetVal(_T("limit"));
58 int limit
= _tstoi(val
);
59 CString rev
= parser
.GetVal(_T("rev"));
63 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
64 limit
= (int)(LONG
)reg
;
67 CString findStr
= parser
.GetVal(_T("findstring"));
68 LONG findType
= parser
.GetLongVal(_T("findtype"));
69 bool findRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE
);
70 if (parser
.HasKey(_T("findtext")))
72 if (parser
.HasKey(_T("findregex")))
76 theApp
.m_pMainWnd
= &dlg
;
77 dlg
.SetParams(orgCmdLinePath
, cmdLinePath
, rev
, range
, limit
);
78 dlg
.SetFilter(findStr
, findType
, findRegex
);
80 if (parser
.HasVal(_T("outfile")))
82 CString sText
= dlg
.GetSelectedHash();
83 CStringUtils::WriteStringToTextFile(parser
.GetVal(L
"outfile"), (LPCTSTR
)sText
, true);