OSDN Git Service

Improvements to Diff of modified version against head
authorColin Law <colin@clanlaw.org.uk>
Tue, 3 Feb 2009 10:32:40 +0000 (10:32 +0000)
committerFrank Li <lznuaa@gmail.com>
Tue, 3 Feb 2009 11:46:43 +0000 (19:46 +0800)
Switched the two windows round so head is in left and modified in right.
Changed heading to show 'Working Copy' instead of '000000'
Removed path from filename in heading.

src/TortoiseProc/Commands/DiffCommand.cpp
src/TortoiseProc/GitDiff.cpp

index 090615a..dd081f8 100644 (file)
@@ -29,7 +29,7 @@ bool DiffCommand::Execute()
        bool bRet = false;\r
        CString path2 = CPathUtils::GetLongPathname(parser.GetVal(_T("path2")));\r
        bool bAlternativeTool = !!parser.HasKey(_T("alternative"));\r
-       bool bBlame = !!parser.HasKey(_T("blame"));\r
+//     bool bBlame = !!parser.HasKey(_T("blame"));\r
        if (path2.IsEmpty())\r
        {\r
                if (cmdLinePath.IsDirectory())\r
@@ -54,7 +54,7 @@ bool DiffCommand::Execute()
 #endif\r
                        {\r
                                //git_revnum_t baseRev = 0;\r
-                               bRet = diff.Diff(&cmdLinePath,&cmdLinePath,git_revnum_t(_T("HEAD")),git_revnum_t(GIT_REV_ZERO));\r
+                               bRet = diff.Diff(&cmdLinePath,&cmdLinePath,git_revnum_t(GIT_REV_ZERO),git_revnum_t(_T("HEAD")));\r
                        }\r
                }\r
        } \r
index 2da12e5..d85f2c3 100644 (file)
@@ -2,6 +2,7 @@
 #include "GitDiff.h"\r
 #include "AppUtils.h"\r
 #include "git.h"\r
+#include "resource.h"\r
 \r
 CGitDiff::CGitDiff(void)\r
 {\r
@@ -62,13 +63,14 @@ int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t &rev1)
        return 0;\r
 }\r
 \r
-int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, git_revnum_t & rev2, bool blame, bool unified)\r
+int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, git_revnum_t & rev2, bool /*blame*/, bool /*unified*/)\r
 {\r
        CString temppath;\r
        GetTempPath(temppath);\r
        Parser(rev1);\r
        Parser(rev2);\r
        CString file1;\r
+       CString title1;\r
        CString cmd;\r
        if(rev1 != GIT_REV_ZERO )\r
        {\r
@@ -77,14 +79,17 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, gi
                                pPath->GetBaseFilename(),\r
                                rev1.Left(6),\r
                                pPath->GetFileExtension());\r
+               title1 = pPath->GetFileOrDirectoryName()+_T(":")+rev1.Left(6);\r
                cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1,pPath->GetGitPathString());\r
                                g_Git.RunLogFile(cmd,file1);\r
        }else\r
        {\r
                file1=g_Git.m_CurrentDir+_T("\\")+pPath->GetWinPathString();\r
+               title1.Format( IDS_DIFF_WCNAME, pPath->GetFileOrDirectoryName() );\r
        }\r
 \r
        CString file2;\r
+       CString title2;\r
        if(rev2 != GIT_REV_ZERO)\r
        {\r
                \r
@@ -93,23 +98,25 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, gi
                                pPath2->GetBaseFilename(),\r
                                rev2.Left(6),\r
                                pPath2->GetFileExtension());\r
+               title2 = pPath2->GetFileOrDirectoryName()+_T(":")+rev2.Left(6);\r
                cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2,pPath2->GetGitPathString());\r
                g_Git.RunLogFile(cmd,file2);\r
        }else\r
        {\r
                file2=g_Git.m_CurrentDir+_T("\\")+pPath2->GetWinPathString();\r
+               title2.Format( IDS_DIFF_WCNAME, pPath2->GetFileOrDirectoryName() );\r
        }\r
        \r
        CAppUtils::DiffFlags flags;\r
        CAppUtils::StartExtDiff(file2,file1,\r
-                                                       pPath2->GetGitPathString()+_T(":")+rev2.Left(6),\r
-                                                       pPath->GetGitPathString()+_T(":")+rev1.Left(6)\r
+                                                       title2,\r
+                                                       title1\r
                                                        ,flags);\r
 \r
        return 0;\r
 }\r
 \r
-int CGitDiff::StartConflictEditor(CTGitPath* file)\r
+int CGitDiff::StartConflictEditor(CTGitPath* /*file*/)\r
 {\r
        return 0;\r
 }
\ No newline at end of file