Can run cleanup without using recycle bin and add dry run option
[TortoiseGit.git] / src / TortoiseProc / TortoiseProc.cpp
blob91cfd516d1bd3d59b730c9c515e370d0c85ce9d8
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2003-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 "TortoiseProc.h"
22 #include "SysImageList.h"
23 #include "..\Utils\CrashReport.h"
24 #include "CmdLineParser.h"
25 #include "Hooks.h"
26 #include "AppUtils.h"
27 #include "PathUtils.h"
28 #include "UnicodeUtils.h"
29 #include "MessageBox.h"
30 //#include "libintl.h"
31 #include "DirFileEnum.h"
32 //#include "SoundUtils.h"
33 #include "GitAdminDir.h"
34 #include "Git.h"
35 #include "SmartHandle.h"
36 #include "Commands\Command.h"
37 #include "..\version.h"
38 #include "JumpListHelpers.h"
39 #include "SinglePropSheetDlg.h"
40 #include "Settings\setmainpage.h"
41 #include "..\Settings\Settings.h"
42 #include "gitindex.h"
43 #include "Libraries.h"
45 #define STRUCT_IOVEC_DEFINED
47 #ifdef _DEBUG
48 #define new DEBUG_NEW
49 #endif
51 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
53 #define APPID (_T("TGIT.TGIT.1") _T(TGIT_PLATFORM))
55 BEGIN_MESSAGE_MAP(CTortoiseProcApp, CWinAppEx)
56 ON_COMMAND(ID_HELP, CWinAppEx::OnHelp)
57 END_MESSAGE_MAP()
59 //CString g_version;
60 //CString CGit::m_MsysGitPath;
61 //////////////////////////////////////////////////////////////////////////
63 CTortoiseProcApp::CTortoiseProcApp()
65 SetDllDirectory(L"");
66 CCrashReport::Instance().AddUserInfoToReport(L"CommandLine", GetCommandLine());
67 EnableHtmlHelp();
68 // int argc = 0;
69 // const char* const * argv = NULL;
70 SYS_IMAGE_LIST();
71 CHooks::Create();
72 m_bLoadUserToolbars = FALSE;
73 m_bSaveState = FALSE;
74 retSuccess = false;
78 CTortoiseProcApp::~CTortoiseProcApp()
80 CHooks::Destroy();
81 SYS_IMAGE_LIST().Cleanup();
84 // The one and only CTortoiseProcApp object
85 CTortoiseProcApp theApp;
86 CString sOrigCWD;
87 HWND hWndExplorer;
89 BOOL CTortoiseProcApp::CheckMsysGitDir()
91 //CGitIndexFileMap map;
92 //int status;
93 //CTGitPath path;
94 //path.SetFromGit(_T("src/gpl.txt"));
95 //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);
96 return g_Git.CheckMsysGitDir();
98 CCrashReportTGit crasher(L"TortoiseGit " _T(APP_X64_STRING));
100 // CTortoiseProcApp initialization
102 BOOL CTortoiseProcApp::InitInstance()
104 CheckUpgrade();
105 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
106 CMFCButton::EnableWindowsTheming();
108 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
109 Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);
111 //set the resource dll for the required language
112 CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
113 long langId = loc;
114 CString langDll;
115 CStringA langpath = CStringA(CPathUtils::GetAppParentDirectory());
116 langpath += "Languages";
117 // bindtextdomain("subversion", (LPCSTR)langpath);
118 // bind_textdomain_codeset("subversion", "UTF-8");
119 HINSTANCE hInst = NULL;
122 langDll.Format(_T("%sLanguages\\TortoiseProc%d.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId);
124 hInst = LoadLibrary(langDll);
126 CString sVer = _T(STRPRODUCTVER);
127 CString sFileVer = CPathUtils::GetVersionFromFile(langDll);
128 if (sFileVer.Compare(sVer)!=0)
130 FreeLibrary(hInst);
131 hInst = NULL;
133 if (hInst != NULL)
135 AfxSetResourceHandle(hInst);
137 else
139 DWORD lid = SUBLANGID(langId);
140 lid--;
141 if (lid > 0)
143 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
145 else
146 langId = 0;
148 } while ((hInst == NULL) && (langId != 0));
149 TCHAR buf[6];
150 _tcscpy_s(buf, _T("en"));
151 langId = loc;
152 // MFC uses a help file with the same name as the application by default,
153 // which means we have to change that default to our language specific help files
154 CString sHelppath = CPathUtils::GetAppDirectory() + _T("TortoiseGit_en.chm");
155 free((void*)m_pszHelpFilePath);
156 m_pszHelpFilePath=_tcsdup(sHelppath);
157 sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
160 CString sLang = _T("_");
161 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf)))
163 sLang += buf;
164 sHelppath.Replace(_T("_en"), sLang);
165 if (PathFileExists(sHelppath))
167 free((void*)m_pszHelpFilePath);
168 m_pszHelpFilePath=_tcsdup(sHelppath);
169 break;
172 sHelppath.Replace(sLang, _T("_en"));
173 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf)))
175 sLang += _T("_");
176 sLang += buf;
177 sHelppath.Replace(_T("_en"), sLang);
178 if (PathFileExists(sHelppath))
180 free((void*)m_pszHelpFilePath);
181 m_pszHelpFilePath=_tcsdup(sHelppath);
182 break;
185 sHelppath.Replace(sLang, _T("_en"));
187 DWORD lid = SUBLANGID(langId);
188 lid--;
189 if (lid > 0)
191 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
193 else
194 langId = 0;
195 } while (langId);
196 setlocale(LC_ALL, "");
198 if(!CheckMsysGitDir())
200 UINT ret = CMessageBox::Show(NULL, IDS_PROC_NOMSYSGIT, IDS_APPNAME, 3, IDI_HAND, IDS_PROC_SETMSYSGITPATH, IDS_PROC_GOTOMSYSGITWEBSITE, IDS_ABORTBUTTON);
201 if(ret == 2)
203 ShellExecute(NULL, NULL, _T("http://code.google.com/p/msysgit/"), NULL, NULL, SW_SHOW);
205 else if(ret == 1)
207 // open settings dialog
208 CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROC_SETTINGS_TITLE)), new CSetMainPage(), this->GetMainWnd()).DoModal();
210 return FALSE;
212 if (CAppUtils::GetMsysgitVersion() < 0x01070a00)
214 int ret = CMessageBox::ShowCheck(NULL, IDS_PROC_OLDMSYSGIT, IDS_APPNAME, 1, IDI_EXCLAMATION, IDS_PROC_GOTOMSYSGITWEBSITE, IDS_ABORTBUTTON, IDS_IGNOREBUTTON, _T("OldMsysgitVersionWarning"), IDS_PROC_NOTSHOWAGAINIGNORE);
215 if (ret == 1)
217 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\OldMsysgitVersionWarning")).removeValue(); // only store answer if it is "Ignore"
218 ShellExecute(NULL, NULL, _T("http://code.google.com/p/msysgit/"), NULL, NULL, SW_SHOW);
219 return FALSE;
221 else if (ret == 2)
223 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\OldMsysgitVersionWarning")).removeValue(); // only store answer if it is "Ignore"
224 return FALSE;
228 // InitCommonControls() is required on Windows XP if an application
229 // manifest specifies use of ComCtl32.dll version 6 or later to enable
230 // visual styles. Otherwise, any window creation will fail.
232 INITCOMMONCONTROLSEX used = {
233 sizeof(INITCOMMONCONTROLSEX),
234 ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_DATE_CLASSES |
235 ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES |
236 ICC_NATIVEFNTCTL_CLASS | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS |
237 ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS |
238 ICC_USEREX_CLASSES | ICC_WIN95_CLASSES
240 InitCommonControlsEx(&used);
241 AfxOleInit();
242 AfxEnableControlContainer();
243 AfxInitRichEdit2();
244 CWinAppEx::InitInstance();
245 SetRegistryKey(_T("TortoiseGit"));
246 AfxGetApp()->m_pszProfileName = _tcsdup(_T("TortoiseProc")); // w/o this ResizableLib will store data under TortoiseGitProc which is not compatible with older versions
248 CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
250 hWndExplorer = NULL;
251 CString sVal = parser.GetVal(_T("hwnd"));
252 if (!sVal.IsEmpty())
253 hWndExplorer = (HWND)_ttoi64(sVal);
255 while (GetParent(hWndExplorer)!=NULL)
256 hWndExplorer = GetParent(hWndExplorer);
257 if (!IsWindow(hWndExplorer))
259 hWndExplorer = NULL;
262 // if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
263 // in a message box
264 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE)==TRUE)
265 AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION);
267 if ( parser.HasKey(_T("path")) && parser.HasKey(_T("pathfile")))
269 CMessageBox::Show(NULL, IDS_ERR_INVALIDPATH, IDS_APPNAME, MB_ICONERROR);
270 return FALSE;
273 CTGitPath cmdLinePath;
274 CTGitPathList pathList;
275 if ( parser.HasKey(_T("pathfile")) )
278 CString sPathfileArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("pathfile")));
280 cmdLinePath.SetFromUnknown(sPathfileArgument);
281 if (pathList.LoadFromFile(cmdLinePath)==false)
282 return FALSE; // no path specified!
283 if ( parser.HasKey(_T("deletepathfile")) )
285 // We can delete the temporary path file, now that we've loaded it
286 ::DeleteFile(cmdLinePath.GetWinPath());
288 // This was a path to a temporary file - it's got no meaning now, and
289 // anybody who uses it again is in for a problem...
290 cmdLinePath.Reset();
293 else
296 CString sPathArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("path")));
297 if (parser.HasKey(_T("expaths")))
299 // an /expaths param means we're started via the buttons in our Win7 library
300 // and that means the value of /expaths is the current directory, and
301 // the selected paths are then added as additional parameters but without a key, only a value
303 // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
304 // we have to escape the backslashes first. Since we're only dealing with paths here, that's
305 // a save bet.
306 // Without this, a command line like:
307 // /command:commit /expaths:"D:\" "D:\Utils"
308 // would fail because the "D:\" is treated as the backslash being the escape char for the quotation
309 // mark and we'd end up with:
310 // argv[1] = /command:commit
311 // argv[2] = /expaths:D:" D:\Utils
312 // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
313 CString cmdLine = GetCommandLineW();
314 cmdLine.Replace(L"\\", L"\\\\");
315 int nArgs = 0;
316 LPWSTR *szArglist = CommandLineToArgvW(cmdLine, &nArgs);
317 if (szArglist)
319 // argument 0 is the process path, so start with 1
320 for (int i=1; i<nArgs; i++)
322 if (szArglist[i][0] != '/')
324 if (!sPathArgument.IsEmpty())
325 sPathArgument += '*';
326 sPathArgument += szArglist[i];
329 sPathArgument.Replace(L"\\\\", L"\\");
331 LocalFree(szArglist);
333 if (sPathArgument.IsEmpty() && parser.HasKey(L"path"))
335 CMessageBox::Show(hWndExplorer, IDS_ERR_INVALIDPATH, IDS_APPNAME, MB_ICONERROR);
336 return FALSE;
338 int asterisk = sPathArgument.Find('*');
339 cmdLinePath.SetFromUnknown(asterisk >= 0 ? sPathArgument.Left(asterisk) : sPathArgument);
340 pathList.LoadFromAsteriskSeparatedString(sPathArgument);
343 if (pathList.GetCount() == 0) {
344 pathList.AddPath(CTGitPath::CTGitPath(g_Git.m_CurrentDir));
347 InitializeJumpList();
348 EnsureGitLibrary(false);
350 // Subversion sometimes writes temp files to the current directory!
351 // Since TSVN doesn't need a specific CWD anyway, we just set it
352 // to the users temp folder: that way, Subversion is guaranteed to
353 // have write access to the CWD
355 DWORD len = GetCurrentDirectory(0, NULL);
356 if (len)
358 auto_buffer<TCHAR> originalCurrentDirectory(len);
359 if (GetCurrentDirectory(len, originalCurrentDirectory))
361 sOrigCWD = originalCurrentDirectory;
362 sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD);
365 TCHAR pathbuf[MAX_PATH];
366 GetTortoiseGitTempPath(MAX_PATH, pathbuf);
367 SetCurrentDirectory(pathbuf);
370 CheckForNewerVersion();
372 if (parser.HasVal(_T("configdir")))
374 // the user can override the location of the Subversion config directory here
375 CString sConfigDir = parser.GetVal(_T("configdir"));
376 // g_GitGlobal.SetConfigDir(sConfigDir);
379 CAutoGeneralHandle TGitMutex = ::CreateMutex(NULL, FALSE, _T("TortoiseGitProc.exe"));
380 if (!g_Git.SetCurrentDir(cmdLinePath.GetWinPathString(), parser.HasKey(_T("submodule")) == TRUE))
382 int i=0;
383 for(i=0;i<pathList.GetCount();i++)
384 if(g_Git.SetCurrentDir(pathList[i].GetWinPath()))
385 break;
388 if(!g_Git.m_CurrentDir.IsEmpty())
390 sOrigCWD = g_Git.m_CurrentDir;
391 SetCurrentDirectory(g_Git.m_CurrentDir);
395 CString err;
398 // requires CWD to be set
399 CGit::m_LogEncode = CAppUtils::GetLogOutputEncode();
401 catch (char* msg)
403 err = CString(msg);
406 if (!err.IsEmpty())
408 UINT choice = CMessageBox::Show(hWndExplorer, err, _T("TortoiseGit"), 1, IDI_ERROR, CString(MAKEINTRESOURCE(IDS_PROC_EDITLOCALGITCONFIG)), CString(MAKEINTRESOURCE(IDS_PROC_EDITGLOBALGITCONFIG)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON)));
409 if (choice == 1)
411 // open the config file with alternative editor
412 CAppUtils::LaunchAlternativeEditor(g_Git.GetGitLocalConfig());
414 else if (choice == 2)
416 // open the global config file with alternative editor
417 CAppUtils::LaunchAlternativeEditor(g_Git.GetGitGlobalConfig());
419 return FALSE;
423 // execute the requested command
424 CommandServer server;
425 Command * cmd = server.GetCommand(parser.GetVal(_T("command")));
426 if (cmd)
428 cmd->SetExplorerHwnd(hWndExplorer);
430 cmd->SetParser(parser);
431 cmd->SetPaths(pathList, cmdLinePath);
433 retSuccess = cmd->Execute();
434 delete cmd;
437 // Look for temporary files left around by TortoiseSVN and
438 // remove them. But only delete 'old' files because some
439 // apps might still be needing the recent ones.
441 DWORD len = GetTortoiseGitTempPath(0, NULL);
442 TCHAR * path = new TCHAR[len + 100];
443 len = GetTortoiseGitTempPath (len+100, path);
444 if (len != 0)
446 CDirFileEnum finder(path);
447 FILETIME systime_;
448 ::GetSystemTimeAsFileTime(&systime_);
449 __int64 systime = (((_int64)systime_.dwHighDateTime)<<32) | ((__int64)systime_.dwLowDateTime);
450 bool isDir;
451 CString filepath;
452 while (finder.NextFile(filepath, &isDir))
454 HANDLE hFile = ::CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, isDir ? FILE_FLAG_BACKUP_SEMANTICS : NULL, NULL);
455 if (hFile != INVALID_HANDLE_VALUE)
457 FILETIME createtime_;
458 if (::GetFileTime(hFile, &createtime_, NULL, NULL))
460 ::CloseHandle(hFile);
461 __int64 createtime = (((_int64)createtime_.dwHighDateTime)<<32) | ((__int64)createtime_.dwLowDateTime);
462 if ((createtime + 864000000000) < systime) //only delete files older than a day
464 ::SetFileAttributes(filepath, FILE_ATTRIBUTE_NORMAL);
465 if (isDir)
466 ::RemoveDirectory(filepath);
467 else
468 ::DeleteFile(filepath);
471 else
472 ::CloseHandle(hFile);
476 delete[] path;
479 // Since the dialog has been closed, return FALSE so that we exit the
480 // application, rather than start the application's message pump.
481 return FALSE;
484 void CTortoiseProcApp::CheckUpgrade()
486 CRegString regVersion = CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
487 CString sVersion = regVersion;
488 if (sVersion.Compare(_T(STRPRODUCTVER))==0)
489 return;
490 // we're starting the first time with a new version!
492 LONG lVersion = 0;
493 int pos = sVersion.Find('.');
494 if (pos > 0)
496 lVersion = (_ttol(sVersion.Left(pos))<<24);
497 lVersion |= (_ttol(sVersion.Mid(pos+1))<<16);
498 pos = sVersion.Find('.', pos+1);
499 lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);
501 else
503 pos = sVersion.Find(',');
504 if (pos > 0)
506 lVersion = (_ttol(sVersion.Left(pos))<<24);
507 lVersion |= (_ttol(sVersion.Mid(pos+1))<<16);
508 pos = sVersion.Find(',', pos+1);
509 lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);
513 #if 0
514 if (lVersion <= 0x01010300)
516 CSoundUtils::RegisterTSVNSounds();
518 #endif
520 if (lVersion <= 0x01040000)
522 CRegStdDWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
525 if (lVersion <= 0x01070600)
527 CoInitialize(NULL);
528 EnsureGitLibrary();
529 CoUninitialize();
530 CRegStdDWORD(_T("Software\\TortoiseGit\\ConvertBase")).removeValue();
531 CRegStdDWORD(_T("Software\\TortoiseGit\\DiffProps")).removeValue();
532 if (CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE) == FALSE)
533 CRegStdDWORD(_T("Software\\TortoiseGit\\VersionCheck")) = FALSE;
536 if (lVersion <= 0x01070E00)
538 CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer")).removeValue();
539 // upgrade to 1.7.15: force recreation of all diff scripts.
540 CAppUtils::SetupDiffScripts(true, CString());
542 CAppUtils::SetupDiffScripts(false, CString());
544 // set the current version so we don't come here again until the next update!
545 regVersion = _T(STRPRODUCTVER);
548 void CTortoiseProcApp::InitializeJumpList()
550 // for Win7 : use a custom jump list
551 CoInitialize(NULL);
552 SetAppID(APPID);
553 DeleteJumpList(APPID);
554 DoInitializeJumpList();
555 CoUninitialize();
558 void CTortoiseProcApp::DoInitializeJumpList()
560 ATL::CComPtr<ICustomDestinationList> pcdl;
561 HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
562 if (FAILED(hr))
563 return;
565 hr = pcdl->SetAppID(APPID);
566 if (FAILED(hr))
567 return;
569 UINT uMaxSlots;
570 ATL::CComPtr<IObjectArray> poaRemoved;
571 hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
572 if (FAILED(hr))
573 return;
575 ATL::CComPtr<IObjectCollection> poc;
576 hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER);
577 if (FAILED(hr))
578 return;
580 CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
581 sTemp.Remove('&');
583 ATL::CComPtr<IShellLink> psl;
584 hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 20, &psl);
585 if (SUCCEEDED(hr)) {
586 poc->AddObject(psl);
588 sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
589 sTemp.Remove('&');
590 psl.Release(); // Need to release the object before calling operator&()
591 hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 19, &psl);
592 if (SUCCEEDED(hr)) {
593 poc->AddObject(psl);
596 ATL::CComPtr<IObjectArray> poa;
597 hr = poc.QueryInterface(&poa);
598 if (SUCCEEDED(hr)) {
599 pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
600 pcdl->CommitList();
604 int CTortoiseProcApp::ExitInstance()
606 Gdiplus::GdiplusShutdown(m_gdiplusToken);
608 CWinAppEx::ExitInstance();
609 if (retSuccess)
610 return 0;
611 return -1;
614 void CTortoiseProcApp::CheckForNewerVersion()
616 // check for newer versions
617 if (CRegDWORD(_T("Software\\TortoiseGit\\VersionCheck"), TRUE) != FALSE)
619 time_t now;
620 struct tm ptm;
622 time(&now);
623 if ((now != 0) && (localtime_s(&ptm, &now)==0))
625 #if PREVIEW
626 // Check daily for new preview releases
627 CRegDWORD oldday = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerDay"), (DWORD)-1);
628 if (((DWORD)oldday) == -1)
629 oldday = ptm.tm_yday;
630 else
632 if ((DWORD)oldday != (DWORD)ptm.tm_yday)
634 oldday = ptm.tm_yday;
635 #else
636 int week = 0;
637 // we don't calculate the real 'week of the year' here
638 // because just to decide if we should check for an update
639 // that's not needed.
640 week = ptm.tm_yday / 7;
642 CRegDWORD oldweek = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD)-1);
643 if (((DWORD)oldweek) == -1)
644 oldweek = week; // first start of TortoiseProc, no update check needed
645 else
647 if ((DWORD)week != oldweek)
649 oldweek = week;
650 #endif
651 TCHAR com[MAX_PATH+100];
652 GetModuleFileName(NULL, com, MAX_PATH);
653 _tcscat_s(com, MAX_PATH+100, _T(" /command:updatecheck"));
655 CAppUtils::LaunchApplication(com, 0, false);