Signed-off-by: Frank Li <lznuaa@gmail.com>
icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(*GitPath);\r
}\r
// relative path\r
icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(*GitPath);\r
}\r
// relative path\r
+ CString rename;\r
+ rename.Format(_T("(from %s)"),GitPath->GetGitOldPathString());\r
+ if(GitPath->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
+ entryname+=rename;\r
+ \r
InsertItem(index, entryname, icon_idx);\r
\r
this->SetItemData(index, (DWORD_PTR)GitPath);\r
InsertItem(index, entryname, icon_idx);\r
\r
this->SetItemData(index, (DWORD_PTR)GitPath);\r
m_bIsDirectory = bIsDirectory;\r
}\r
\r
m_bIsDirectory = bIsDirectory;\r
}\r
\r
-void CTGitPath::SetFromGit(const CString& sPath)\r
+void CTGitPath::SetFromGit(const CString& sPath,CString *oldpath)\r
{\r
Reset();\r
m_sFwdslashPath = sPath;\r
SanitizeRootPath(m_sFwdslashPath, true);\r
{\r
Reset();\r
m_sFwdslashPath = sPath;\r
SanitizeRootPath(m_sFwdslashPath, true);\r
+ if(oldpath)\r
+ m_sOldFwdslashPath = *oldpath;\r
}\r
\r
void CTGitPath::SetFromWin(LPCTSTR pPath)\r
}\r
\r
void CTGitPath::SetFromWin(LPCTSTR pPath)\r
return m_sFwdslashPath;\r
}\r
\r
return m_sFwdslashPath;\r
}\r
\r
+const CString &CTGitPath::GetGitOldPathString() const\r
+{\r
+ return m_sOldFwdslashPath;\r
+}\r
#if 0\r
const char* CTGitPath::GetGitApiPath(apr_pool_t *pool) const\r
{\r
#if 0\r
const char* CTGitPath::GetGitApiPath(apr_pool_t *pool) const\r
{\r
while( pos>=0 )\r
{\r
one=log.Tokenize(_T("\n"),pos);\r
while( pos>=0 )\r
{\r
one=log.Tokenize(_T("\n"),pos);\r
if(one[0]==_T(':'))\r
{\r
int tabstart=0;\r
if(one[0]==_T(':'))\r
{\r
int tabstart=0;\r
- path.SetFromGit(pathname);\r
+ int ac=path.ParserAction(action);\r
+ if(ac & CTGitPath::LOGACTIONS_REPLACED)\r
+ {\r
+ CString oldname;\r
+ int oldnametab=pathname.Find(_T("\t"));\r
+ if(oldnametab>0)\r
+ path.SetFromGit(pathname.Right(pathname.GetLength()-oldnametab-1),&pathname.Left(oldnametab));\r
+ else\r
+ {\r
+ ASSERT(FALSE);\r
+ path.SetFromGit(pathname);\r
+ }\r
+ }else\r
+ path.SetFromGit(pathname);\r
+ path.m_Action=ac;\r
//action must be set after setfromgit. SetFromGit will clear all status. \r
//action must be set after setfromgit. SetFromGit will clear all status. \r
- this->m_Action|=path.ParserAction(action);\r
AddPath(path);\r
}\r
}\r
\r
}else\r
{\r
AddPath(path);\r
}\r
}\r
\r
}else\r
{\r
int tabstart=0;\r
path.Reset();\r
CString StatAdd=(one.Tokenize(_T("\t"),tabstart));\r
int tabstart=0;\r
path.Reset();\r
CString StatAdd=(one.Tokenize(_T("\t"),tabstart));\r
break;\r
CString StatDel=(one.Tokenize(_T("\t"),tabstart));\r
//SetFromGit will reset all context of GitRev\r
break;\r
CString StatDel=(one.Tokenize(_T("\t"),tabstart));\r
//SetFromGit will reset all context of GitRev\r
- path.SetFromGit(one.Right(one.GetLength()-tabstart));\r
+ one=one.Right(one.GetLength()-tabstart);\r
+ int rename=one.Find(_T(" => "));\r
+ if(rename>0)\r
+ {\r
+ path.SetFromGit(one.Right(one.GetLength()-rename-4),&one.Left(rename));\r
+ }else\r
+ path.SetFromGit(one.Right(one.GetLength()-tabstart));\r
\r
CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());\r
if(GitPath)\r
\r
CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());\r
if(GitPath)\r
*/\r
void SetFromGit(const char* pPath);\r
void SetFromGit(const char* pPath, bool bIsDirectory);\r
*/\r
void SetFromGit(const char* pPath);\r
void SetFromGit(const char* pPath, bool bIsDirectory);\r
- void SetFromGit(const CString& sPath);\r
+ void SetFromGit(const CString& sPath,CString *OldPath=NULL);\r
+ \r
/**\r
* Set the path as UNICODE with backslashes\r
*/\r
/**\r
* Set the path as UNICODE with backslashes\r
*/\r
* Returns the path with forward slashes.\r
*/\r
const CString& GetGitPathString() const;\r
* Returns the path with forward slashes.\r
*/\r
const CString& GetGitPathString() const;\r
+\r
+ const CString& GetGitOldPathString() const;\r
/**\r
* Returns the path completely prepared to be fed the the Git APIs\r
* It will be in UTF8, with URLs escaped, if necessary\r
/**\r
* Returns the path completely prepared to be fed the the Git APIs\r
* It will be in UTF8, with URLs escaped, if necessary\r
mutable CString m_sUIPath;\r
mutable CStringA m_sUTF8FwdslashPath;\r
mutable CStringA m_sUTF8FwdslashPathEscaped;\r
mutable CString m_sUIPath;\r
mutable CStringA m_sUTF8FwdslashPath;\r
mutable CStringA m_sUTF8FwdslashPathEscaped;\r
+\r
+ //used for rename case\r
+ mutable CString m_sOldBackslashPath;\r
+ mutable CString m_sOldFwdslashPath;\r
+ \r
// Have we yet determined if this is a directory or not?\r
mutable bool m_bDirectoryKnown;\r
mutable bool m_bIsDirectory;\r
// Have we yet determined if this is a directory or not?\r
mutable bool m_bDirectoryKnown;\r
mutable bool m_bIsDirectory;\r
//first add all the unversioned files the user selected\r
//and check if all versioned files are selected\r
int nUnchecked = 0;\r
//first add all the unversioned files the user selected\r
//and check if all versioned files are selected\r
int nUnchecked = 0;\r
m_bRecursive = true;\r
int nListItems = m_ListCtrl.GetItemCount();\r
\r
m_bRecursive = true;\r
int nListItems = m_ListCtrl.GetItemCount();\r
\r
//std::set<CString> checkedLists;\r
//std::set<CString> uncheckedLists;\r
\r
//std::set<CString> checkedLists;\r
//std::set<CString> uncheckedLists;\r
\r
- CString checkedfiles;\r
- CString uncheckedfiles;\r
+ //CString checkedfiles;\r
+ //CString uncheckedfiles;\r
+\r
+ CString cmd;\r
+ CString out;\r
\r
for (int j=0; j<nListItems; j++)\r
{\r
\r
for (int j=0; j<nListItems; j++)\r
{\r
bCheckedInExternal = true;\r
}\r
#endif\r
bCheckedInExternal = true;\r
}\r
#endif\r
+ cmd.Format(_T("git.exe update-index -- \"%s\""),entry->GetGitPathString());\r
+ g_Git.Run(cmd,&out);\r
+ nchecked++;\r
//checkedLists.insert(entry->GetGitPathString());\r
//checkedLists.insert(entry->GetGitPathString());\r
- checkedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
+// checkedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
}\r
else\r
{\r
//uncheckedLists.insert(entry->GetGitPathString());\r
}\r
else\r
{\r
//uncheckedLists.insert(entry->GetGitPathString());\r
- uncheckedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
+ if(entry->m_Action & CTGitPath::LOGACTIONS_ADDED)\r
+ { //To init git repository, there are not HEAD, so we can use git reset command\r
+ cmd.Format(_T("git.exe rm --cache -- \"%s\""),entry->GetGitPathString());\r
+ g_Git.Run(cmd,&out); \r
+ }\r
+ else\r
+ {\r
+ cmd.Format(_T("git.exe reset -- %s"),entry->GetGitPathString());\r
+ g_Git.Run(cmd,&out);\r
+ }\r
+\r
+ // uncheckedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
#if 0\r
if ((entry->status != Git_wc_status_unversioned) &&\r
(entry->status != Git_wc_status_ignored))\r
#if 0\r
if ((entry->status != Git_wc_status_unversioned) &&\r
(entry->status != Git_wc_status_ignored))\r
- CString cmd;\r
- CString out;\r
- if(uncheckedfiles.GetLength()>0)\r
- {\r
- cmd.Format(_T("git.exe reset -- %s"),uncheckedfiles);\r
- g_Git.Run(cmd,&out);\r
- }\r
+ //if(uncheckedfiles.GetLength()>0)\r
+ //{\r
+ // cmd.Format(_T("git.exe reset -- %s"),uncheckedfiles);\r
+ // g_Git.Run(cmd,&out);\r
+ //}\r
- if(checkedfiles.GetLength()>0)\r
+ //if(checkedfiles.GetLength()>0)\r
+ if(nchecked)\r
- cmd.Format(_T("git.exe update-index -- %s"),checkedfiles);\r
- g_Git.Run(cmd,&out);\r
+ // cmd.Format(_T("git.exe update-index -- %s"),checkedfiles);\r
+ // g_Git.Run(cmd,&out);\r
\r
CString tempfile=::GetTempFile();\r
CFile file(tempfile,CFile::modeReadWrite|CFile::modeCreate );\r
\r
CString tempfile=::GetTempFile();\r
CFile file(tempfile,CFile::modeReadWrite|CFile::modeCreate );\r
\r
CTGitPath *path = (CTGitPath*)m_ListCtrl.GetItemData(i);\r
\r
\r
CTGitPath *path = (CTGitPath*)m_ListCtrl.GetItemData(i);\r
\r
+ if(path == NULL)\r
+ continue;\r
+\r
CString sPartPath =path->GetGitPathString();\r
m_autolist.insert(sPartPath);\r
\r
CString sPartPath =path->GetGitPathString();\r
m_autolist.insert(sPartPath);\r
\r
- RelativePath=".\explorer.ico"\r
+ RelativePath="..\Resources\explorer.ico"\r
- RelativePath="..\Resources\explorer.ico"\r
+ RelativePath=".\explorer.ico"\r
- RelativePath=".\newfolder.ico"\r
+ RelativePath="..\Resources\newfolder.ico"\r
- RelativePath="..\Resources\newfolder.ico"\r
+ RelativePath=".\newfolder.ico"\r
- RelativePath=".\open.ico"\r
+ RelativePath="..\Resources\open.ico"\r
- RelativePath="..\Resources\open.ico"\r
+ RelativePath=".\open.ico"\r
- RelativePath=".\save.ico"\r
+ RelativePath="..\Resources\save.ico"\r
- RelativePath="..\Resources\save.ico"\r
+ RelativePath=".\save.ico"\r
- RelativePath=".\saveas.ico"\r
+ RelativePath="..\Resources\saveas.ico"\r
- RelativePath="..\Resources\saveas.ico"\r
+ RelativePath=".\saveas.ico"\r
- RelativePath=".\up.ico"\r
+ RelativePath="..\Resources\up.ico"\r
- RelativePath="..\Resources\up.ico"\r
+ RelativePath=".\up.ico"\r
>\r
</File>\r
</Filter>\r
>\r
</File>\r
</Filter>\r
+ <Filter\r
+ Name="Compare"\r
+ >\r
+ <File\r
+ RelativePath=".\Commands\ShowCompareCommand.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\Commands\ShowCompareCommand.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
</Filter>\r
<Filter\r
Name="Utility Dialogs"\r
</Filter>\r
<Filter\r
Name="Utility Dialogs"\r
RelativePath=".\SwitchDlg.h"\r
>\r
</File>\r
RelativePath=".\SwitchDlg.h"\r
>\r
</File>\r
- <Filter\r
- Name="Compare"\r
- >\r
- <File\r
- RelativePath=".\Commands\ShowCompareCommand.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Commands\ShowCompareCommand.h"\r
- >\r
- </File>\r
- </Filter>\r
</Filter>\r
<File\r
RelativePath="Resource.h"\r
</Filter>\r
<File\r
RelativePath="Resource.h"\r
<DebugSettings\r
Command="$(TargetPath)"\r
WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
<DebugSettings\r
Command="$(TargetPath)"\r
WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
- CommandArguments="/command:log /path:"D:\\test4\\tt""\r
+ CommandArguments="/command:commit /path:"D:\\test4\\tt""\r
Attach="false"\r
DebuggerType="3"\r
Remote="1"\r
Attach="false"\r
DebuggerType="3"\r
Remote="1"\r