Restore CWD after calling CFileDialog
[TortoiseGit.git] / test / GitIndexTest / GitIndexTest.cpp
blob03ff7f8a76c44bd14a8932e0d6f120e64b244da6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2010 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // GitIndexTest.cpp : Defines the entry point for the console application.
23 #include "stdafx.h"
24 #include "gitstatus.h"
25 #include "gitindex.h"
26 #include "gitdll.h"
27 #include "TGitPath.h"
29 int _tmain(int argc, _TCHAR* argv[])
31 CTGitPath path;
32 CString root;
33 TCHAR buff[256];
35 GetCurrentDirectory(256,buff);
36 path.SetFromWin(buff);
38 if(!path.HasAdminDir(&root))
40 printf("not in git repository\n");
41 return -1;
44 CGitIndexList list;
45 list.ReadIndex(root+_T("\\.git\\index"));
47 CGitHeadFileList filelist;
48 filelist.ReadHeadHash(buff);
49 _tprintf(_T("update %d\n"), filelist.CheckHeadUpdate());
51 git_init();
52 // filelist.ReadTree();
54 WIN32_FIND_DATA data;
55 CString str(buff);
56 str+=_T("\\*.*");
57 GitStatus status;
59 HANDLE handle = FindFirstFile(str,&data);
60 while(FindNextFile(handle,&data))
62 if( _tcsnccmp(data.cFileName, _T(".."),2) ==0)
63 continue;
64 if( _tcsnccmp(data.cFileName, _T("."),1) ==0 )
65 continue;
67 CString spath(buff);
68 spath += _T("\\");
69 spath += data.cFileName;
70 CTGitPath path(spath);
72 TCHAR name[100];
73 int t1,t2;
74 t1 = ::GetCurrentTime();
75 status.GetStatusString(status.GetAllStatus(path), 100,name);
76 t2 = ::GetCurrentTime();
78 _tprintf(_T("%s - %s - %d\n"),data.cFileName, name, t2-t1);
82 return 0;