From: Frank Li Date: Tue, 30 Dec 2008 15:07:06 +0000 (+0800) Subject: Fix File List Del\Add switch problem and enable prevdiff command X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dc3540ede1ffaac43133f4313999af30194e403d;p=tortoisegit%2FTortoiseGitJp.git Fix File List Del\Add switch problem and enable prevdiff command --- diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 60c81ec..f475f5d 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -182,14 +182,21 @@ int CGit::GetLog(CString& logOut, CString &hash, int count) } -int CGit::GetShortLog(CString &logOut) +int CGit::GetShortLog(CString &logOut,CTGitPath * path, int count) { CString cmd; CString log; - cmd=("git.exe log --topo-order -n100 --pretty=format:\""); + int n; + if(count<0) + n=100; + else + n=count; + cmd.Format(_T("git.exe log --topo-order -n%d --pretty=format:\""),n); BuildOutputFormat(log,false); - cmd += log; - cmd += CString(_T("\" HEAD~40..HEAD")); + cmd += log+_T("\""); + if (path) + cmd+= _T(" -- \"")+path->GetGitPathString()+_T("\""); + //cmd += CString(_T("\" HEAD~40..HEAD")); return Run(cmd,&logOut); } diff --git a/src/Git/Git.h b/src/Git/Git.h index 653a493..748ee10 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -53,7 +53,7 @@ public: git_revnum_t GetHash(CString &friendname); int BuildOutputFormat(CString &format,bool IsFull=TRUE); - int GetShortLog(CString &log); + int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1); }; diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index a1d1cb0..2bab662 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -1394,7 +1394,7 @@ int CGitStatusListCtrl::GetColumnIndex(int mask) int i=0; for(i=0;i<32;i++) if(mask&0x1) - return i; + return i-1; else mask=mask>>1; return -1; diff --git a/src/Git/GitStatusListCtrl.h b/src/Git/GitStatusListCtrl.h index c3146da..0584d30 100644 --- a/src/Git/GitStatusListCtrl.h +++ b/src/Git/GitStatusListCtrl.h @@ -37,7 +37,7 @@ #define SVNSLC_COLDATE 0x000000100 #define SVNSLC_COLMODIFICATIONDATE 0x000000200 #define SVNSLC_COLADD 0x000000400 -#define SVNSLC_COLDEL 0x000000600 +#define SVNSLC_COLDEL 0x000000800 #define SVNSLC_NUMCOLUMNS 12 //#define SVNSLC_COLREMOTESTATUS 0x000000010 diff --git a/src/TortoiseProc/Commands/PrevDiffCommand.cpp b/src/TortoiseProc/Commands/PrevDiffCommand.cpp index 7b3bb4c..8eeb4cb 100644 --- a/src/TortoiseProc/Commands/PrevDiffCommand.cpp +++ b/src/TortoiseProc/Commands/PrevDiffCommand.cpp @@ -22,6 +22,7 @@ #include "GitStatus.h" #include "MessageBox.h" #include "ChangedDlg.h" +#include "LogDlgHelper.h" bool PrevDiffCommand::Execute() { @@ -43,8 +44,28 @@ bool PrevDiffCommand::Execute() if (1) { - CGitDiff diff; - bRet = diff.Diff(&cmdLinePath, git_revnum_t(_T("HEAD")), git_revnum_t(_T("HEAD~1")), false); + CString hash; + CString logout; + + CLogDataVector revs; + revs.ParserShortLog(&cmdLinePath,2); + if( revs.size() == 0) + { + CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR); + return FALSE; + } + + if( revs.size() == 1 ) + { + CGitDiff diff; + bRet = diff.DiffNull(&cmdLinePath,revs[0].m_CommitHash); + } + + if( revs.size() == 2 ) + { + CGitDiff diff; + bRet = diff.Diff(&cmdLinePath, revs[0].m_CommitHash, revs[1].m_CommitHash, false); + } } else { diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 8c18684..fdb9f2a 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -27,6 +27,40 @@ int CGitDiff::Parser(git_revnum_t &rev) } return 0; } +int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t &rev1) +{ + CString temppath; + GetTempPath(temppath); + Parser(rev1); + CString file1; + CString nullfile; + CString cmd; + if(rev1 != GIT_REV_ZERO ) + { + file1.Format(_T("%s%s_%s%s"), + temppath, + pPath->GetBaseFilename(), + rev1.Left(6), + pPath->GetFileExtension()); + cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1,pPath->GetGitPathString()); + g_Git.RunLogFile(cmd,file1); + }else + { + file1=g_Git.m_CurrentDir+_T("\\")+pPath->GetWinPathString(); + } + + CString tempfile=::GetTempFile(); + CStdioFile file(tempfile,CFile::modeReadWrite|CFile::modeCreate ); + //file.WriteString(); + file.Close(); + + CAppUtils::DiffFlags flags; + CAppUtils::StartExtDiff(tempfile,file1, + _T("NULL"), + pPath->GetGitPathString()+_T(":")+rev1.Left(6) + ,flags); + return 0; +} int CGitDiff::Diff(CTGitPath * pPath, git_revnum_t & rev1, git_revnum_t & rev2, bool blame, bool unified) { @@ -67,7 +101,7 @@ int CGitDiff::Diff(CTGitPath * pPath, git_revnum_t & rev1, git_revnum_t & rev2, } CAppUtils::DiffFlags flags; - CAppUtils::StartExtDiff(file1,file2, + CAppUtils::StartExtDiff(file2,file1, pPath->GetGitPathString()+_T(":")+rev2.Left(6), pPath->GetGitPathString()+_T(":")+rev1.Left(6) ,flags); diff --git a/src/TortoiseProc/GitDiff.h b/src/TortoiseProc/GitDiff.h index effe970..b6162c0 100644 --- a/src/TortoiseProc/GitDiff.h +++ b/src/TortoiseProc/GitDiff.h @@ -11,4 +11,5 @@ public: static int Parser(git_revnum_t &rev); static int Diff(CTGitPath * pPath, git_revnum_t & rev1, git_revnum_t & rev2, bool blame=false, bool unified=false); + static int DiffNull(CTGitPath *pPath, git_revnum_t &rev1); }; diff --git a/src/TortoiseProc/LogDataVector.cpp b/src/TortoiseProc/LogDataVector.cpp index e4ea92d..e33cea1 100644 --- a/src/TortoiseProc/LogDataVector.cpp +++ b/src/TortoiseProc/LogDataVector.cpp @@ -63,7 +63,7 @@ //#include "EditPropertiesDlg.h" #include "FileDiffDlg.h" -int CLogDataVector::ParserShortLog() +int CLogDataVector::ParserShortLog(CTGitPath *path ,int count ) { CString log; GitRev rev; @@ -71,7 +71,7 @@ int CLogDataVector::ParserShortLog() CString begin; begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN); - g_Git.GetShortLog(log); + g_Git.GetShortLog(log,path,count); if(log.GetLength()==0) return 0; diff --git a/src/TortoiseProc/LogDlgHelper.h b/src/TortoiseProc/LogDlgHelper.h index d4d15cb..7b53399 100644 --- a/src/TortoiseProc/LogDlgHelper.h +++ b/src/TortoiseProc/LogDlgHelper.h @@ -58,7 +58,7 @@ public: } void ClearAll(); int ParserFromLog(); - int ParserShortLog(); + int ParserShortLog(CTGitPath *path =NULL,int count = -1 ); int FetchFullInfo(int i); Lanes m_Lanes; diff --git a/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user b/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user index a9acb41..199d68e 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user +++ b/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user @@ -11,7 +11,7 @@