From: Frank Li Date: Mon, 20 Jul 2009 15:33:41 +0000 (+0800) Subject: Get Change File List at Sync Dialog X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=33a7adaf9a66738c1ec2f82195b0e1f3c14aa724;p=tortoisegit%2FTortoiseGitJp.git Get Change File List at Sync Dialog --- diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 4e5e951..f17e638 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -655,6 +655,30 @@ git_revnum_t CGit::GetHash(const CString &friendname) return out; } +int CGit::GetCommitDiffList(CString &rev1,CString &rev2,CTGitPathList &outputlist) +{ + CString cmd; + + if(rev1 == GIT_REV_ZERO || rev2 == GIT_REV_ZERO) + { + //rev1=+_T(""); + if(rev1 == GIT_REV_ZERO) + cmd.Format(_T("git.exe diff -r --raw -C -M --numstat -z %s"),rev2); + else + cmd.Format(_T("git.exe diff -r -R --raw -C -M --numstat -z %s"),rev1); + }else + { + cmd.Format(_T("git.exe diff-tree -r --raw -C -M --numstat -z %s %s"),rev2,rev1); + } + + BYTE_VECTOR out; + if(g_Git.Run(cmd,&out)) + return -1; + + outputlist.ParserFromLog(out); + +} + int CGit::GetTagList(STRING_VECTOR &list) { int ret; diff --git a/src/Git/Git.h b/src/Git/Git.h index 2cc24fd..f025ff6 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -119,6 +119,8 @@ public: CString GetFullRefName(CString shortRefName); //Removes 'refs/heads/' or just 'refs'. Example: refs/heads/master -> master static CString StripRefName(CString refName); + + int GetCommitDiffList(CString &rev1,CString &rev2,CTGitPathList &outpathlist); }; extern void GetTempPath(CString &path); diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 58463a7..bdd1131 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -1252,6 +1252,9 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders /* = true */) { + DeleteAllItems(); + for(int i=0;iAddEntry((CTGitPath *)&checkedList[i],0,i); return ; #if 0 diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 3be546c..c95d38e 100644 Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ diff --git a/src/TortoiseProc/FileDiffDlg.cpp b/src/TortoiseProc/FileDiffDlg.cpp index a8d60e0..94f518d 100644 --- a/src/TortoiseProc/FileDiffDlg.cpp +++ b/src/TortoiseProc/FileDiffDlg.cpp @@ -252,24 +252,9 @@ UINT CFileDiffDlg::DiffThread() // return 0; // } #endif - CString cmd; - CString rev1=m_rev1.m_CommitHash; - if(this->m_rev1.m_CommitHash == GIT_REV_ZERO || this->m_rev2.m_CommitHash == GIT_REV_ZERO) - { - rev1=+_T(""); - if(this->m_rev1.m_CommitHash == GIT_REV_ZERO) - cmd.Format(_T("git.exe diff -r --raw -C -M --numstat -z %s"),m_rev2.m_CommitHash); - else - cmd.Format(_T("git.exe diff -r -R --raw -C -M --numstat -z %s"),m_rev1.m_CommitHash); - }else - { - cmd.Format(_T("git.exe diff-tree -r --raw -C -M --numstat -z %s %s"),m_rev2.m_CommitHash,rev1); - } - BYTE_VECTOR out; - g_Git.Run(cmd,&out); - this->m_arFileList.ParserFromLog(out); - + g_Git.GetCommitDiffList(m_rev1.m_CommitHash,m_rev2.m_CommitHash,m_arFileList); + CString sFilterText; m_cFilter.GetWindowText(sFilterText); m_cFileList.SetRedraw(false); diff --git a/src/TortoiseProc/SyncDlg.cpp b/src/TortoiseProc/SyncDlg.cpp index 0d5c108..63a4d60 100644 --- a/src/TortoiseProc/SyncDlg.cpp +++ b/src/TortoiseProc/SyncDlg.cpp @@ -34,6 +34,7 @@ CSyncDlg::CSyncDlg(CWnd* pParent /*=NULL*/) , m_bAutoLoadPuttyKey(FALSE) { m_pTooltip=&this->m_tooltips; + m_bInited=false; } CSyncDlg::~CSyncDlg() @@ -189,6 +190,8 @@ BOOL CSyncDlg::OnInitDialog() this->LoadBranchInfo(); + this->m_bInited=true; + FetchOutList(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE @@ -208,6 +211,8 @@ BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg) } void CSyncDlg::FetchOutList() { + if(!m_bInited) + return; m_OutChangeFileList.Clear(); this->m_OutLogList.Clear(); @@ -242,11 +247,29 @@ void CSyncDlg::FetchOutList() CString localbranch; localbranch=this->m_ctrlLocalBranch.GetString(); - if(localbranch != m_OutLocalBranch && m_OutRemoteBranch != remotebranch) + if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch) { m_OutLogList.ClearText(); m_OutLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, &remotebranch,&localbranch); + + CString str; + if(m_OutLogList.GetItemCount() == 0) + { + str.Format(_T("No commits ahead \"%s\""),remotebranch); + m_OutLogList.ShowText(str); + this->m_ctrlStatus.SetWindowText(str); + this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); + } + else + { + str.Format(_T("%d commits ahead \"%s\""),m_OutLogList.GetItemCount(),remotebranch); + this->m_ctrlStatus.SetWindowText(str); + g_Git.GetCommitDiffList(localbranch,remotebranch,m_arOutChangeList); + m_OutChangeFileList.Show(0,this->m_arOutChangeList); + m_OutChangeFileList.SetEmptyString(CString(_T("No changed file"))); + this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE); + } } this->m_OutLocalBranch=localbranch; this->m_OutRemoteBranch=remotebranch; diff --git a/src/TortoiseProc/SyncDlg.h b/src/TortoiseProc/SyncDlg.h index 1ca5fa1..f1ead82 100644 --- a/src/TortoiseProc/SyncDlg.h +++ b/src/TortoiseProc/SyncDlg.h @@ -52,12 +52,15 @@ protected: CMFCTabCtrl m_ctrlTabCtrl; CBalloon m_tooltips; + BOOL m_bInited; + CGitLogList m_OutLogList; CGitLogList m_InLogList; CGitStatusListCtrl m_OutChangeFileList; CGitStatusListCtrl m_InChangeFileList; CGitStatusListCtrl m_ConflictFileList; + CTGitPathList m_arOutChangeList; virtual void LocalBranchChange(){FetchOutList();}; virtual void RemoteBranchChange(){FetchOutList();};