#include "GitConfig.h"\r
\r
#define MAX_DIRBUFFER 1000\r
+CString CGit::ms_LastMsysGitDir;\r
CGit g_Git;\r
CGit::CGit(void)\r
{\r
{\r
SECURITY_ATTRIBUTES sa;\r
HANDLE hRead, hWrite;\r
- HANDLE hStdioFile;\r
+ HANDLE hStdioFile = NULL;\r
\r
sa.nLength = sizeof(SECURITY_ATTRIBUTES);\r
sa.lpSecurityDescriptor=NULL;\r
if(mask& CGit::LOG_INFO_DETECT_RENAME )\r
param += _T(" -M ");\r
\r
+ if(mask& CGit::LOG_INFO_FIRST_PARENT )\r
+ param += _T(" --first-parent ");\r
+ \r
+ if(mask& CGit::LOG_INFO_NO_MERGE )\r
+ param += _T(" --no-merges ");\r
+\r
+ if(mask& CGit::LOG_INFO_FOLLOW)\r
+ param += _T(" --follow ");\r
+\r
param+=hash;\r
\r
- cmd.Format(_T("git.exe log %s -z --topo-order --parents %s --pretty=format:\""),\r
+ cmd.Format(_T("git.exe log %s -z --topo-order %s --parents --pretty=format:\""),\r
num,param);\r
\r
BuildOutputFormat(log,!(mask&CGit::LOG_INFO_ONLY_HASH));\r
CloseHandle(pi.hProcess);\r
CloseHandle(houtfile);\r
return GIT_SUCCESS;\r
- return 0;\r
+// return 0;\r
}\r
\r
git_revnum_t CGit::GetHash(CString &friendname)\r
{\r
CRegString msysinstalldir=CRegString(REG_MSYSGIT_INSTALL,_T(""),FALSE,HKEY_LOCAL_MACHINE);\r
str=msysinstalldir;\r
- str+="\\bin";\r
+ // check it has a trailing blank\r
+ if (str.Right(1) != _T("\\"))\r
+ {\r
+ str += _T("\\");\r
+ }\r
+ str+=_T("bin");\r
msysdir=str;\r
msysdir.write();\r
\r
{ \r
_tdupenv_s(&home,&size,_T("USERPROFILE")); \r
_tputenv_s(_T("HOME"),home);\r
- free(home);\r
}\r
+ free(home);\r
+ \r
//set path\r
_tdupenv_s(&oldpath,&size,_T("PATH")); \r
\r
CString path;\r
+ CString unterminated_path = str; // path to msysgit without semicolon\r
+ CString oldpath_s = oldpath;\r
path.Format(_T("%s;"),str);\r
- path+=oldpath;\r
-\r
- _tputenv_s(_T("PATH"),path);\r
-\r
+ // check msysgit not already in path\r
+ if ( oldpath_s.Find( path ) < 0 && oldpath_s.Right( unterminated_path.GetLength() ) != unterminated_path )\r
+ {\r
+ // not already there, see if we have to take out one we added last time\r
+ if ( ms_LastMsysGitDir != _T("") )\r
+ {\r
+ // we have added one so take it out\r
+ int index = oldpath_s.Find( ms_LastMsysGitDir );\r
+ if ( index >= 0 )\r
+ {\r
+ oldpath_s = oldpath_s.Left( index ) + \r
+ oldpath_s.Right( oldpath_s.GetLength() - (index+ms_LastMsysGitDir.GetLength()) );\r
+ }\r
+ }\r
+ // save the new msysdir path that we are about to add\r
+ ms_LastMsysGitDir = path;\r
+ // add the new one on the front of the existing path\r
+ path+=oldpath_s;\r
+ _tputenv_s(_T("PATH"),path);\r
+ }\r
free(oldpath);\r
\r
CString cmd,out;\r