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