1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
4 // Copyright (C) 2007-2011 - TortoiseGit
5 // Copyright (C) 2011 Sven Strickroth <email@cs-ware.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "DiffCommand.h"
23 #include "PathUtils.h"
25 #include "ChangedDlg.h"
27 #include "GitStatus.h"
29 bool DiffCommand::Execute()
32 CString path2
= CPathUtils::GetLongPathname(parser
.GetVal(_T("path2")));
33 bool bAlternativeTool
= !!parser
.HasKey(_T("alternative"));
34 // bool bBlame = !!parser.HasKey(_T("blame"));
37 if (this->orgCmdLinePath
.IsDirectory())
40 dlg
.m_pathList
= CTGitPathList(cmdLinePath
);
47 //diff.SetAlternativeTool(bAlternativeTool);
48 if ( parser
.HasKey(_T("startrev")) && parser
.HasKey(_T("endrev")) )
50 bRet
= !!diff
.Diff(&cmdLinePath
,&cmdLinePath
,git_revnum_t(parser
.GetVal(_T("startrev"))),git_revnum_t(parser
.GetVal(_T("endrev"))));
54 // check if it is a newly added (but uncommitted) file
55 git_wc_status_kind status
= git_wc_status_none
;
57 if (orgCmdLinePath
.HasAdminDir(&topDir
))
58 GitStatus::GetFileStatus(topDir
, cmdLinePath
.GetWinPathString(), &status
, true);
59 if (status
== git_wc_status_added
)
60 cmdLinePath
.m_Action
= cmdLinePath
.LOGACTIONS_ADDED
;
62 bRet
= !!diff
.Diff(&cmdLinePath
,&cmdLinePath
,git_revnum_t(GIT_REV_ZERO
),git_revnum_t(_T("HEAD")));
67 bRet
= CAppUtils::StartExtDiff(
68 path2
, orgCmdLinePath
.GetWinPathString(), CString(), CString(),
69 CString(), CString(), git_revnum_t(GIT_REV_ZERO
), git_revnum_t(GIT_REV_ZERO
),
70 CAppUtils::DiffFlags().AlternativeTool(bAlternativeTool
));