Dropped auto_buffer
[TortoiseGit.git] / src / TortoiseProc / TortoiseProc.cpp
blobd22ba4365cfced59b65d3253cb940875abfca0da
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;
75 m_gdiplusToken = NULL;
79 CTortoiseProcApp::~CTortoiseProcApp()
81 CHooks::Destroy();
82 SYS_IMAGE_LIST().Cleanup();
85 // The one and only CTortoiseProcApp object
86 CTortoiseProcApp theApp;
87 CString sOrigCWD;
88 HWND hWndExplorer;
90 BOOL CTortoiseProcApp::CheckMsysGitDir()
92 //CGitIndexFileMap map;
93 //int status;
94 //CTGitPath path;
95 //path.SetFromGit(_T("src/gpl.txt"));
96 //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);
97 return g_Git.CheckMsysGitDir();
99 CCrashReportTGit crasher(L"TortoiseGit " _T(APP_X64_STRING));
101 // CTortoiseProcApp initialization
103 BOOL CTortoiseProcApp::InitInstance()
105 CheckUpgrade();
106 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
107 CMFCButton::EnableWindowsTheming();
109 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
110 Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);
112 //set the resource dll for the required language
113 CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
114 long langId = loc;
115 CString langDll;
116 CStringA langpath = CStringA(CPathUtils::GetAppParentDirectory());
117 langpath += "Languages";
118 // bindtextdomain("subversion", (LPCSTR)langpath);
119 // bind_textdomain_codeset("subversion", "UTF-8");
120 HINSTANCE hInst = NULL;
123 langDll.Format(_T("%sLanguages\\TortoiseProc%d.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId);
125 hInst = LoadLibrary(langDll);
127 CString sVer = _T(STRPRODUCTVER);
128 CString sFileVer = CPathUtils::GetVersionFromFile(langDll);
129 if (sFileVer.Compare(sVer)!=0)
131 FreeLibrary(hInst);
132 hInst = NULL;
134 if (hInst != NULL)
136 AfxSetResourceHandle(hInst);
138 else
140 DWORD lid = SUBLANGID(langId);
141 lid--;
142 if (lid > 0)
144 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
146 else
147 langId = 0;
149 } while ((hInst == NULL) && (langId != 0));
150 TCHAR buf[6];
151 _tcscpy_s(buf, _T("en"));
152 langId = loc;
153 // MFC uses a help file with the same name as the application by default,
154 // which means we have to change that default to our language specific help files
155 CString sHelppath = CPathUtils::GetAppDirectory() + _T("TortoiseGit_en.chm");
156 free((void*)m_pszHelpFilePath);
157 m_pszHelpFilePath=_tcsdup(sHelppath);
158 sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");
161 CString sLang = _T("_");
162 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf)))
164 sLang += buf;
165 sHelppath.Replace(_T("_en"), sLang);
166 if (PathFileExists(sHelppath))
168 free((void*)m_pszHelpFilePath);
169 m_pszHelpFilePath=_tcsdup(sHelppath);
170 break;
173 sHelppath.Replace(sLang, _T("_en"));
174 if (GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf)))
176 sLang += _T("_");
177 sLang += buf;
178 sHelppath.Replace(_T("_en"), sLang);
179 if (PathFileExists(sHelppath))
181 free((void*)m_pszHelpFilePath);
182 m_pszHelpFilePath=_tcsdup(sHelppath);
183 break;
186 sHelppath.Replace(sLang, _T("_en"));
188 DWORD lid = SUBLANGID(langId);
189 lid--;
190 if (lid > 0)
192 langId = MAKELANGID(PRIMARYLANGID(langId), lid);
194 else
195 langId = 0;
196 } while (langId);
197 setlocale(LC_ALL, "");
199 if(!CheckMsysGitDir())
201 UINT ret = CMessageBox::Show(NULL, IDS_PROC_NOMSYSGIT, IDS_APPNAME, 3, IDI_HAND, IDS_PROC_SETMSYSGITPATH, IDS_PROC_GOTOMSYSGITWEBSITE, IDS_ABORTBUTTON);
202 if(ret == 2)
204 ShellExecute(NULL, NULL, _T("http://code.google.com/p/msysgit/"), NULL, NULL, SW_SHOW);
206 else if(ret == 1)
208 // open settings dialog
209 CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROC_SETTINGS_TITLE)), new CSetMainPage(), this->GetMainWnd()).DoModal();
211 return FALSE;
213 if (CAppUtils::GetMsysgitVersion() < 0x01070a00)
215 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);
216 if (ret == 1)
218 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\OldMsysgitVersionWarning")).removeValue(); // only store answer if it is "Ignore"
219 ShellExecute(NULL, NULL, _T("http://code.google.com/p/msysgit/"), NULL, NULL, SW_SHOW);
220 return FALSE;
222 else if (ret == 2)
224 CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\OldMsysgitVersionWarning")).removeValue(); // only store answer if it is "Ignore"
225 return FALSE;
229 // InitCommonControls() is required on Windows XP if an application
230 // manifest specifies use of ComCtl32.dll version 6 or later to enable
231 // visual styles. Otherwise, any window creation will fail.
233 INITCOMMONCONTROLSEX used = {
234 sizeof(INITCOMMONCONTROLSEX),
235 ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_DATE_CLASSES |
236 ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES |
237 ICC_NATIVEFNTCTL_CLASS | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS |
238 ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS |
239 ICC_USEREX_CLASSES | ICC_WIN95_CLASSES
241 InitCommonControlsEx(&used);
242 AfxOleInit();
243 AfxEnableControlContainer();
244 AfxInitRichEdit2();
245 CWinAppEx::InitInstance();
246 SetRegistryKey(_T("TortoiseGit"));
247 AfxGetApp()->m_pszProfileName = _tcsdup(_T("TortoiseProc")); // w/o this ResizableLib will store data under TortoiseGitProc which is not compatible with older versions
249 CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
251 hWndExplorer = NULL;
252 CString sVal = parser.GetVal(_T("hwnd"));
253 if (!sVal.IsEmpty())
254 hWndExplorer = (HWND)_ttoi64(sVal);
256 while (GetParent(hWndExplorer)!=NULL)
257 hWndExplorer = GetParent(hWndExplorer);
258 if (!IsWindow(hWndExplorer))
260 hWndExplorer = NULL;
263 // if HKCU\Software\TortoiseGit\Debug is not 0, show our command line
264 // in a message box
265 if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE)==TRUE)
266 AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION);
268 if ( parser.HasKey(_T("path")) && parser.HasKey(_T("pathfile")))
270 CMessageBox::Show(NULL, IDS_ERR_INVALIDPATH, IDS_APPNAME, MB_ICONERROR);
271 return FALSE;
274 CTGitPath cmdLinePath;
275 CTGitPathList pathList;
276 if ( parser.HasKey(_T("pathfile")) )
279 CString sPathfileArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("pathfile")));
281 cmdLinePath.SetFromUnknown(sPathfileArgument);
282 if (pathList.LoadFromFile(cmdLinePath)==false)
283 return FALSE; // no path specified!
284 if ( parser.HasKey(_T("deletepathfile")) )
286 // We can delete the temporary path file, now that we've loaded it
287 ::DeleteFile(cmdLinePath.GetWinPath());
289 // This was a path to a temporary file - it's got no meaning now, and
290 // anybody who uses it again is in for a problem...
291 cmdLinePath.Reset();
294 else
297 CString sPathArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("path")));
298 if (parser.HasKey(_T("expaths")))
300 // an /expaths param means we're started via the buttons in our Win7 library
301 // and that means the value of /expaths is the current directory, and
302 // the selected paths are then added as additional parameters but without a key, only a value
304 // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
305 // we have to escape the backslashes first. Since we're only dealing with paths here, that's
306 // a save bet.
307 // Without this, a command line like:
308 // /command:commit /expaths:"D:\" "D:\Utils"
309 // would fail because the "D:\" is treated as the backslash being the escape char for the quotation
310 // mark and we'd end up with:
311 // argv[1] = /command:commit
312 // argv[2] = /expaths:D:" D:\Utils
313 // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
314 CString cmdLine = GetCommandLineW();
315 cmdLine.Replace(L"\\", L"\\\\");
316 int nArgs = 0;
317 LPWSTR *szArglist = CommandLineToArgvW(cmdLine, &nArgs);
318 if (szArglist)
320 // argument 0 is the process path, so start with 1
321 for (int i=1; i<nArgs; i++)
323 if (szArglist[i][0] != '/')
325 if (!sPathArgument.IsEmpty())
326 sPathArgument += '*';
327 sPathArgument += szArglist[i];
330 sPathArgument.Replace(L"\\\\", L"\\");
332 LocalFree(szArglist);
334 if (sPathArgument.IsEmpty() && parser.HasKey(L"path"))
336 CMessageBox::Show(hWndExplorer, IDS_ERR_INVALIDPATH, IDS_APPNAME, MB_ICONERROR);
337 return FALSE;
339 int asterisk = sPathArgument.Find('*');
340 cmdLinePath.SetFromUnknown(asterisk >= 0 ? sPathArgument.Left(asterisk) : sPathArgument);
341 pathList.LoadFromAsteriskSeparatedString(sPathArgument);
344 if (pathList.GetCount() == 0) {
345 pathList.AddPath(CTGitPath::CTGitPath(g_Git.m_CurrentDir));
348 InitializeJumpList();
349 EnsureGitLibrary(false);
351 // Subversion sometimes writes temp files to the current directory!
352 // Since TSVN doesn't need a specific CWD anyway, we just set it
353 // to the users temp folder: that way, Subversion is guaranteed to
354 // have write access to the CWD
356 DWORD len = GetCurrentDirectory(0, NULL);
357 if (len)
359 std::unique_ptr<TCHAR[]> originalCurrentDirectory(new TCHAR[len]);
360 if (GetCurrentDirectory(len, originalCurrentDirectory.get()))
362 sOrigCWD = originalCurrentDirectory.get();
363 sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD);
366 TCHAR pathbuf[MAX_PATH];
367 GetTortoiseGitTempPath(MAX_PATH, pathbuf);
368 SetCurrentDirectory(pathbuf);
371 CheckForNewerVersion();
373 if (parser.HasVal(_T("configdir")))
375 // the user can override the location of the Subversion config directory here
376 CString sConfigDir = parser.GetVal(_T("configdir"));
377 // g_GitGlobal.SetConfigDir(sConfigDir);
380 CAutoGeneralHandle TGitMutex = ::CreateMutex(NULL, FALSE, _T("TortoiseGitProc.exe"));
381 if (!g_Git.SetCurrentDir(cmdLinePath.GetWinPathString(), parser.HasKey(_T("submodule")) == TRUE))
383 int i=0;
384 for(i=0;i<pathList.GetCount();i++)
385 if(g_Git.SetCurrentDir(pathList[i].GetWinPath()))
386 break;
389 if(!g_Git.m_CurrentDir.IsEmpty())
391 sOrigCWD = g_Git.m_CurrentDir;
392 SetCurrentDirectory(g_Git.m_CurrentDir);
396 CString err;
399 // requires CWD to be set
400 CGit::m_LogEncode = CAppUtils::GetLogOutputEncode();
402 catch (char* msg)
404 err = CString(msg);
407 if (!err.IsEmpty())
409 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)));
410 if (choice == 1)
412 // open the config file with alternative editor
413 CAppUtils::LaunchAlternativeEditor(g_Git.GetGitLocalConfig());
415 else if (choice == 2)
417 // open the global config file with alternative editor
418 CAppUtils::LaunchAlternativeEditor(g_Git.GetGitGlobalConfig());
420 return FALSE;
424 // execute the requested command
425 CommandServer server;
426 Command * cmd = server.GetCommand(parser.GetVal(_T("command")));
427 if (cmd)
429 cmd->SetExplorerHwnd(hWndExplorer);
431 cmd->SetParser(parser);
432 cmd->SetPaths(pathList, cmdLinePath);
434 retSuccess = cmd->Execute();
435 delete cmd;
438 // Look for temporary files left around by TortoiseSVN and
439 // remove them. But only delete 'old' files because some
440 // apps might still be needing the recent ones.
442 DWORD len = GetTortoiseGitTempPath(0, NULL);
443 TCHAR * path = new TCHAR[len + 100];
444 len = GetTortoiseGitTempPath (len+100, path);
445 if (len != 0)
447 CDirFileEnum finder(path);
448 FILETIME systime_;
449 ::GetSystemTimeAsFileTime(&systime_);
450 __int64 systime = (((_int64)systime_.dwHighDateTime)<<32) | ((__int64)systime_.dwLowDateTime);
451 bool isDir;
452 CString filepath;
453 while (finder.NextFile(filepath, &isDir))
455 HANDLE hFile = ::CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, isDir ? FILE_FLAG_BACKUP_SEMANTICS : NULL, NULL);
456 if (hFile != INVALID_HANDLE_VALUE)
458 FILETIME createtime_;
459 if (::GetFileTime(hFile, &createtime_, NULL, NULL))
461 ::CloseHandle(hFile);
462 __int64 createtime = (((_int64)createtime_.dwHighDateTime)<<32) | ((__int64)createtime_.dwLowDateTime);
463 if ((createtime + 864000000000) < systime) //only delete files older than a day
465 ::SetFileAttributes(filepath, FILE_ATTRIBUTE_NORMAL);
466 if (isDir)
467 ::RemoveDirectory(filepath);
468 else
469 ::DeleteFile(filepath);
472 else
473 ::CloseHandle(hFile);
477 delete[] path;
480 // Since the dialog has been closed, return FALSE so that we exit the
481 // application, rather than start the application's message pump.
482 return FALSE;
485 void CTortoiseProcApp::CheckUpgrade()
487 CRegString regVersion = CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));
488 CString sVersion = regVersion;
489 if (sVersion.Compare(_T(STRPRODUCTVER))==0)
490 return;
491 // we're starting the first time with a new version!
493 LONG lVersion = 0;
494 int pos = sVersion.Find('.');
495 if (pos > 0)
497 lVersion = (_ttol(sVersion.Left(pos))<<24);
498 lVersion |= (_ttol(sVersion.Mid(pos+1))<<16);
499 pos = sVersion.Find('.', pos+1);
500 lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);
502 else
504 pos = sVersion.Find(',');
505 if (pos > 0)
507 lVersion = (_ttol(sVersion.Left(pos))<<24);
508 lVersion |= (_ttol(sVersion.Mid(pos+1))<<16);
509 pos = sVersion.Find(',', pos+1);
510 lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);
514 #if 0
515 if (lVersion <= 0x01010300)
517 CSoundUtils::RegisterTSVNSounds();
519 #endif
521 if (lVersion <= 0x01040000)
523 CRegStdDWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();
526 if (lVersion <= 0x01070600)
528 CoInitialize(NULL);
529 EnsureGitLibrary();
530 CoUninitialize();
531 CRegStdDWORD(_T("Software\\TortoiseGit\\ConvertBase")).removeValue();
532 CRegStdDWORD(_T("Software\\TortoiseGit\\DiffProps")).removeValue();
533 if (CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE) == FALSE)
534 CRegStdDWORD(_T("Software\\TortoiseGit\\VersionCheck")) = FALSE;
537 if (lVersion <= 0x01070E00)
539 CRegStdDWORD(_T("Software\\TortoiseGit\\CheckNewer")).removeValue();
540 // upgrade to 1.7.15: force recreation of all diff scripts.
541 CAppUtils::SetupDiffScripts(true, CString());
543 CAppUtils::SetupDiffScripts(false, CString());
545 // set the current version so we don't come here again until the next update!
546 regVersion = _T(STRPRODUCTVER);
549 void CTortoiseProcApp::InitializeJumpList()
551 // for Win7 : use a custom jump list
552 CoInitialize(NULL);
553 SetAppID(APPID);
554 DeleteJumpList(APPID);
555 DoInitializeJumpList();
556 CoUninitialize();
559 void CTortoiseProcApp::DoInitializeJumpList()
561 ATL::CComPtr<ICustomDestinationList> pcdl;
562 HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
563 if (FAILED(hr))
564 return;
566 hr = pcdl->SetAppID(APPID);
567 if (FAILED(hr))
568 return;
570 UINT uMaxSlots;
571 ATL::CComPtr<IObjectArray> poaRemoved;
572 hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
573 if (FAILED(hr))
574 return;
576 ATL::CComPtr<IObjectCollection> poc;
577 hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER);
578 if (FAILED(hr))
579 return;
581 CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
582 sTemp.Remove('&');
584 ATL::CComPtr<IShellLink> psl;
585 hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 20, &psl);
586 if (SUCCEEDED(hr)) {
587 poc->AddObject(psl);
589 sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
590 sTemp.Remove('&');
591 psl.Release(); // Need to release the object before calling operator&()
592 hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 19, &psl);
593 if (SUCCEEDED(hr)) {
594 poc->AddObject(psl);
597 ATL::CComPtr<IObjectArray> poa;
598 hr = poc.QueryInterface(&poa);
599 if (SUCCEEDED(hr)) {
600 pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
601 pcdl->CommitList();
605 int CTortoiseProcApp::ExitInstance()
607 Gdiplus::GdiplusShutdown(m_gdiplusToken);
609 CWinAppEx::ExitInstance();
610 if (retSuccess)
611 return 0;
612 return -1;
615 void CTortoiseProcApp::CheckForNewerVersion()
617 // check for newer versions
618 if (CRegDWORD(_T("Software\\TortoiseGit\\VersionCheck"), TRUE) != FALSE)
620 time_t now;
621 struct tm ptm;
623 time(&now);
624 if ((now != 0) && (localtime_s(&ptm, &now)==0))
626 #if PREVIEW
627 // Check daily for new preview releases
628 CRegDWORD oldday = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerDay"), (DWORD)-1);
629 if (((DWORD)oldday) == -1)
630 oldday = ptm.tm_yday;
631 else
633 if ((DWORD)oldday != (DWORD)ptm.tm_yday)
635 oldday = ptm.tm_yday;
636 #else
637 int week = 0;
638 // we don't calculate the real 'week of the year' here
639 // because just to decide if we should check for an update
640 // that's not needed.
641 week = ptm.tm_yday / 7;
643 CRegDWORD oldweek = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD)-1);
644 if (((DWORD)oldweek) == -1)
645 oldweek = week; // first start of TortoiseProc, no update check needed
646 else
648 if ((DWORD)week != oldweek)
650 oldweek = week;
651 #endif
652 TCHAR com[MAX_PATH+100];
653 GetModuleFileName(NULL, com, MAX_PATH);
654 _tcscat_s(com, MAX_PATH+100, _T(" /command:updatecheck"));
656 CAppUtils::LaunchApplication(com, 0, false);