X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=src%2FGit%2FGit.cpp;h=94a9738c2ae0a42024d89d728e170d4bd2949f3c;hb=658e7d1c3bd8e072736cd8b212c394078bc8affc;hp=0c2933e5ec4a330581f79550d3aaa7c45e811656;hpb=866fbfa194d3fd6cc05fc3499026a1b2c2d286d8;p=tortoisegit%2FTortoiseGitJp.git diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 0c2933e..94a9738 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -2,6 +2,7 @@ #include "Git.h" #include "atlconv.h" #include "GitRev.h" +#include "registry.h" #define MAX_DIRBUFFER 1000 CGit g_Git; @@ -181,7 +182,7 @@ int CGit::BuildOutputFormat(CString &format,bool IsFull) log.Format(_T("#<%c>%%b%%n"),LOG_REV_COMMIT_BODY); format += log; } - log.Format(_T("#<%c>%%H%%n"),LOG_REV_COMMIT_HASH); + log.Format(_T("#<%c>%%m%%H%%n"),LOG_REV_COMMIT_HASH); format += log; log.Format(_T("#<%c>%%P%%n"),LOG_REV_COMMIT_PARENT); format += log; @@ -194,21 +195,39 @@ int CGit::BuildOutputFormat(CString &format,bool IsFull) return 0; } -int CGit::GetLog(CString& logOut, CString &hash, int count) +int CGit::GetLog(CString& logOut, CString &hash, CTGitPath *path ,int count,int mask) { CString cmd; CString log; CString num; CString since; + + CString file; + + if(path) + file.Format(_T(" -- \"%s\""),path->GetGitPathString()); + if(count>0) num.Format(_T("-n%d"),count); - cmd.Format(_T("git.exe log %s -C --numstat --raw --pretty=format:\""), - num); + CString param; + + if(mask& LOG_INFO_STAT ) + param += _T(" --numstat "); + if(mask& LOG_INFO_FILESTATE) + param += _T(" --raw "); + + if(mask& LOG_INFO_FULLHISTORY) + param += _T(" --full-history "); + + cmd.Format(_T("git.exe log %s -C --left-right --boundary --topo-order --parents %s --pretty=format:\""), + num,param); + BuildOutputFormat(log); cmd += log; - cmd += CString(_T("\" "))+hash; + cmd += CString(_T("\" "))+hash+file; + return Run(cmd,&logOut); } @@ -222,7 +241,7 @@ int CGit::GetShortLog(CString &logOut,CTGitPath * path, int count) n=100; else n=count; - cmd.Format(_T("git.exe log --topo-order -n%d --pretty=format:\""),n); + cmd.Format(_T("git.exe log --left-right --boundary --topo-order -n%d --pretty=format:\""),n); BuildOutputFormat(log,false); cmd += log+_T("\""); if (path) @@ -408,7 +427,7 @@ int CGit::GetMapHashToFriendName(MAP_HASH_NAME &map) { int ret; CString cmd,output; - cmd=_T("git show-ref"); + cmd=_T("git show-ref -d"); ret=g_Git.Run(cmd,&output); if(!ret) { @@ -431,4 +450,52 @@ int CGit::GetMapHashToFriendName(MAP_HASH_NAME &map) } } return ret; +} + +BOOL CGit::CheckMsysGitDir() +{ + CRegString msysdir=CRegString(_T("Software\\TortoiseGit\\MSysGit"),_T(""),FALSE,HKEY_LOCAL_MACHINE); + CString str=msysdir; + if(str.IsEmpty()) + { + CRegString msysinstalldir=CRegString(_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1\\InstallLocation"),_T(""),FALSE,HKEY_LOCAL_MACHINE); + str=msysinstalldir; + str+="\\bin"; + msysdir=str; + msysdir.write(); + + } + //CGit::m_MsysGitPath=str; + + TCHAR *oldpath,*home; + size_t size; + + _tdupenv_s(&home,&size,_T("HOME")); + + if(home == NULL) + { + _tdupenv_s(&home,&size,_T("USERPROFILE")); + _tputenv_s(_T("HOME"),home); + free(home); + } + //set path + _tdupenv_s(&oldpath,&size,_T("PATH")); + + CString path; + path.Format(_T("%s;"),str); + path+=oldpath; + + _tputenv_s(_T("PATH"),path); + + free(oldpath); + + CString cmd,out; + cmd=_T("git.exe --version"); + if(g_Git.Run(cmd,&out)) + { + return false; + } + else + return true; + } \ No newline at end of file