OSDN Git Service

Fix Issue 77: "Show differencess" against a deleted file will cause TortoiseMerge...
authorFrank Li <lznuaa@gmail.com>
Fri, 24 Apr 2009 14:19:57 +0000 (22:19 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 24 Apr 2009 14:19:57 +0000 (22:19 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/TortoiseProc/GitDiff.cpp
src/TortoiseProc/GitDiff.h

index 7260bc6..e538bac 100644 (file)
@@ -4000,13 +4000,16 @@ void CGitStatusListCtrl::StartDiff(int fileindex)
 \r
        if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO)\r
        {\r
-               if(!g_Git.IsInitRepos())\r
+               if( g_Git.IsInitRepos())\r
+                       CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex),\r
+                               CString(GIT_REV_ZERO));                 \r
+               else if( file1.m_Action&CTGitPath::LOGACTIONS_DELETED )\r
+                       CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex),\r
+                                       GitRev::GetHead(),false);                               \r
+               else\r
                        CGitDiff::Diff(&file1,&file2,\r
                                CString(GIT_REV_ZERO),\r
                                        GitRev::GetHead());\r
-               else\r
-                       CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex),\r
-                               CString(GIT_REV_ZERO));\r
        }else\r
        {\r
                CGitDiff::Diff(&file1,&file2,\r
index 49ea5e6..3f45e1f 100644 (file)
@@ -28,7 +28,7 @@ int CGitDiff::Parser(git_revnum_t &rev)
        }\r
        return 0;\r
 }\r
-int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t &rev1)\r
+int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t &rev1,bool bIsAdd)\r
 {\r
        CString temppath;\r
        GetTempPath(temppath);\r
@@ -56,10 +56,17 @@ int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t &rev1)
        file.Close();\r
        \r
        CAppUtils::DiffFlags flags;\r
-       CAppUtils::StartExtDiff(tempfile,file1,\r
+\r
+       if(bIsAdd)\r
+               CAppUtils::StartExtDiff(tempfile,file1,\r
                                                        _T("NULL"),\r
                                                        pPath->GetGitPathString()+_T(":")+rev1.Left(6)\r
                                                        ,flags);\r
+       else\r
+               CAppUtils::StartExtDiff(file1,tempfile,\r
+                                                       pPath->GetGitPathString()+_T(":")+rev1.Left(6)\r
+                                                       ,_T("NULL"),flags);\r
+\r
        return 0;\r
 }\r
 \r
index a2e5385..4a7c048 100644 (file)
@@ -12,5 +12,5 @@ public:
 \r
        // Use two path to handle rename cases\r
        static int Diff(CTGitPath * pPath1, CTGitPath *pPath2 ,git_revnum_t & rev1, git_revnum_t & rev2, bool blame=false, bool unified=false);\r
-       static int DiffNull(CTGitPath *pPath, git_revnum_t &rev1);\r
+       static int DiffNull(CTGitPath *pPath, git_revnum_t &rev1,bool bIsAdd=true);\r
 };\r