1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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 "PullCommand.h"
23 //#include "SVNProgressDlg.h"
24 #include "StringUtils.h"
26 #include "MessageBox.h"
27 #include "PullFetchDlg.h"
28 #include "ProgressDlg.h"
29 #include "FileDiffDlg.h"
33 #include "ChangedDlg.h"
35 bool PullCommand::Execute()
37 if (!GitAdminDir().HasAdminDir(g_Git
.m_CurrentDir
)) {
38 CMessageBox::Show(hwndExplorer
, IDS_NOWORKINGCOPY
, IDS_APPNAME
, MB_ICONERROR
);
44 if(dlg
.DoModal()==IDOK
)
51 CAppUtils::LaunchPAgent(NULL
,&dlg
.m_RemoteURL
);
58 hashOld
= g_Git
.GetHash(_T("HEAD"));
63 MessageBox(NULL
, _T("Could not get HEAD hash.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
68 cmdRebase
= "--rebase ";
78 ffonly
= _T("--ff-only");
81 squash
=_T("--squash");
84 nocommit
=_T("--no-commit");
86 int ver
= CAppUtils::GetMsysgitVersion();
88 if(ver
>= 0x01070203) //above 1.7.0.2
89 cmdRebase
+= _T("--progress ");
91 cmd
.Format(_T("git.exe pull -v %s %s %s %s %s \"%s\" %s"), cmdRebase
, noff
, ffonly
, squash
, nocommit
, url
, dlg
.m_RemoteBranchName
);
92 CProgressDlg progress
;
93 progress
.m_GitCmd
= cmd
;
94 progress
.m_PostCmdList
.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_DIFFS
)));
95 progress
.m_PostCmdList
.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_LOG
)));
97 CTGitPath gitPath
= g_Git
.m_CurrentDir
;
98 if (gitPath
.HasSubmodules())
99 progress
.m_PostCmdList
.Add(CString(MAKEINTRESOURCE(IDS_PROC_SUBMODULESUPDATE
)));
101 //progress.m_PostCmdList.Add(_T("Show Conflict"));
103 if (parser
.HasVal(_T("closeonend")))
104 progress
.m_bAutoCloseOnSuccess
= !!parser
.GetLongVal(_T("closeonend"));
106 int ret
= progress
.DoModal();
108 if (ret
== IDOK
&& progress
.m_GitStatus
== 1 && progress
.m_LogText
.Find(_T("CONFLICT")) >= 0 && CMessageBox::Show(NULL
, IDS_SEECHANGES
, IDS_APPNAME
, MB_YESNO
| MB_ICONINFORMATION
) == IDYES
)
111 dlg
.m_pathList
.AddPath(CTGitPath());
117 CString hashNew
= g_Git
.GetHash(L
"HEAD");
119 if( ret
== IDC_PROGRESS_BUTTON1
)
121 if(hashOld
== hashNew
)
123 if(progress
.m_GitStatus
== 0)
124 CMessageBox::Show(NULL
, IDS_UPTODATE
, IDS_APPNAME
, MB_OK
| MB_ICONINFORMATION
);
129 dlg
.SetDiff(NULL
, hashNew
, hashOld
);
134 else if ( ret
== IDC_PROGRESS_BUTTON1
+1 )
136 if(hashOld
== hashNew
)
138 if(progress
.m_GitStatus
== 0)
139 CMessageBox::Show(NULL
, IDS_UPTODATE
, IDS_APPNAME
, MB_OK
| MB_ICONINFORMATION
);
146 //dlg.SetParams(cmdLinePath);
147 dlg
.SetParams(CTGitPath(_T("")),CTGitPath(_T("")),_T(""), hashOld
, hashNew
, 0);
148 // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge")));
149 // val = parser.GetVal(_T("propspath"));
150 // if (!val.IsEmpty())
151 // dlg.SetProjectPropertiesPath(CTSVNPath(val));
156 else if (ret
== IDC_PROGRESS_BUTTON1
+ 2 && gitPath
.HasSubmodules())
159 sCmd
.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git
.m_CurrentDir
);
161 CAppUtils::RunTortoiseProc(sCmd
);