OSDN Git Service

Add log encoding support
authorFrank Li <lznuaa@gmail.com>
Tue, 12 Jan 2010 14:48:40 +0000 (22:48 +0800)
committerFrank Li <lznuaa@gmail.com>
Tue, 12 Jan 2010 14:48:40 +0000 (22:48 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
ext/gitdll/gitdll.c
ext/gitdll/gitdll.h
ext/tgit
src/Git/GitRev.cpp
src/TortoiseProc/GitLogListBase.cpp

index 253ef79..5a1d6f1 100644 (file)
@@ -134,6 +134,9 @@ int git_parse_commit(GIT_COMMIT *commit)
 \r
        memcpy(commit->m_hash,p->object.sha1,GIT_HASH_SIZE);\r
 \r
+       commit->m_Encode = NULL;\r
+       commit->m_EncodeSize = 0;\r
+\r
        if(p->buffer == NULL)\r
                return -1;\r
 \r
@@ -159,6 +162,17 @@ int git_parse_commit(GIT_COMMIT *commit)
                        while((*pbuf) && (*pbuf == '\n'))\r
                                pbuf ++;\r
 \r
+                       if( strncmp(pbuf, "encoding",8) == 0 )\r
+                       {\r
+                               pbuf += 9;\r
+                               commit->m_Encode=pbuf;\r
+                               end = strchr(pbuf,'\n');\r
+                               commit->m_EncodeSize=end -pbuf;\r
+\r
+                               pbuf = end +1;\r
+                               while((*pbuf) && (*pbuf == '\n'))\r
+                                       pbuf ++;\r
+                       }\r
                        commit->m_Subject=pbuf;\r
                        end = strchr(pbuf,'\n');\r
                        if( end == 0)\r
@@ -186,6 +200,9 @@ int git_get_commit_from_hash(GIT_COMMIT *commit, GIT_HASH hash)
        int ret = 0;\r
        \r
        struct commit *p;\r
+       \r
+       memset(commit,0,sizeof(GIT_COMMIT));\r
+\r
        commit->m_pGitCommit = p = lookup_commit(hash);\r
 \r
        if(commit == NULL)\r
index 2af8830..c4fbb30 100644 (file)
@@ -59,6 +59,8 @@ typedef struct GIT_COMMIT_DATA
        char *   m_Body;\r
        int              m_BodySize;\r
        void *   m_pGitCommit; /** internal used */\r
+       char *   m_Encode;\r
+       int              m_EncodeSize;\r
 \r
 } GIT_COMMIT;\r
 \r
index 6ee5d48..8fe4e29 160000 (submodule)
--- a/ext/tgit
+++ b/ext/tgit
@@ -1 +1 @@
-Subproject commit 6ee5d4821cd7cc7a057ab60bf1b57322fedf5b41
+Subproject commit 8fe4e297ad77be0d8a25483e830d9b1695bbd2d9
index b3bc325..b075ad9 100644 (file)
@@ -3,6 +3,7 @@
 #include "GitRev.h"\r
 #include "Git.h"\r
 #include "GitDLL.h"\r
+#include "UnicodeUtils.h"\r
 \r
 class CException; //Just in case afx.h is not included (cannot be included in every project which uses this file)\r
 \r
@@ -358,27 +359,36 @@ int GitRev::ParserParentFromCommit(GIT_COMMIT *commit)
 \r
 int GitRev::ParserFromCommit(GIT_COMMIT *commit)\r
 {\r
+       int encode =CP_UTF8;\r
+       \r
+       if(commit->m_Encode != 0 && commit->m_EncodeSize != 0)\r
+       {\r
+               CString str;\r
+               g_Git.StringAppend(&str, (BYTE*)commit->m_Encode, CP_UTF8, commit->m_EncodeSize);\r
+               encode = CUnicodeUtils::GetCPCode(str);\r
+       }\r
+\r
        this->m_AuthorDate = commit->m_Author.Date;\r
        \r
        this->m_AuthorEmail.Empty();\r
-       g_Git.StringAppend(&m_AuthorEmail,(BYTE*)commit->m_Author.Email,CP_ACP,commit->m_Author.EmailSize);\r
+       g_Git.StringAppend(&m_AuthorEmail,(BYTE*)commit->m_Author.Email,CP_UTF8,commit->m_Author.EmailSize);\r
 \r
        this->m_AuthorName.Empty();\r
-       g_Git.StringAppend(&m_AuthorName,(BYTE*)commit->m_Author.Name,CP_ACP,commit->m_Author.NameSize);\r
+       g_Git.StringAppend(&m_AuthorName,(BYTE*)commit->m_Author.Name,CP_UTF8,commit->m_Author.NameSize);\r
        \r
        this->m_Body.Empty();\r
-       g_Git.StringAppend(&m_Body,(BYTE*)commit->m_Body,CP_ACP,commit->m_BodySize);\r
+       g_Git.StringAppend(&m_Body,(BYTE*)commit->m_Body,encode,commit->m_BodySize);\r
 \r
        this->m_CommitterDate = commit->m_Committer.Date;\r
        \r
        this->m_CommitterEmail.Empty();\r
-       g_Git.StringAppend(&m_CommitterEmail, (BYTE*)commit->m_Committer.Email,CP_ACP, commit->m_Committer.EmailSize);\r
+       g_Git.StringAppend(&m_CommitterEmail, (BYTE*)commit->m_Committer.Email,CP_UTF8, commit->m_Committer.EmailSize);\r
 \r
        this->m_CommitterName.Empty();\r
-       g_Git.StringAppend(&m_CommitterName, (BYTE*)commit->m_Committer.Name,CP_ACP, commit->m_Committer.NameSize);\r
+       g_Git.StringAppend(&m_CommitterName, (BYTE*)commit->m_Committer.Name,CP_UTF8, commit->m_Committer.NameSize);\r
 \r
        this->m_Subject.Empty();\r
-       g_Git.StringAppend(&m_Subject, (BYTE*)commit->m_Subject,CP_ACP,commit->m_SubjectSize);\r
+       g_Git.StringAppend(&m_Subject, (BYTE*)commit->m_Subject,encode,commit->m_SubjectSize);\r
        \r
        return 0;\r
 }
\ No newline at end of file
index cb46112..5f64ad9 100644 (file)
@@ -1763,7 +1763,7 @@ int CGitLogListBase::BeginFetchLog()
        int mask;\r
        mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;\r
 //     if(this->m_bAllBranch)\r
-       mask |= m_ShowMask |CGit::LOG_INFO_ALL_BRANCH;\r
+       mask |= m_ShowMask ;\r
        \r
        this->m_arShownList.RemoveAll();\r
 \r