OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / src / Git / GitHash.h
index 65a407f..4d65ba7 100644 (file)
@@ -29,17 +29,18 @@ public:
                {\r
                        unsigned char a;\r
                        a=0;\r
-                       for(int j=2*i;j<2*i+1;j++)\r
+                       for(int j=2*i;j<=2*i+1;j++)\r
                        {\r
+                               a =a<<4;\r
+\r
                                TCHAR ch = str[j];\r
                                if(ch >= _T('0') && ch <= _T('9'))\r
                                        a |= (ch - _T('0'))&0xF;\r
                                else if(ch >=_T('A') && ch <= _T('F'))\r
-                                       a |= (ch - _T('A'))&0xF;\r
+                                       a |= ((ch - _T('A'))&0xF) + 10 ;\r
                                else if(ch >=_T('a') && ch <= _T('f'))\r
-                                       a |= (ch - _T('a'))&0xF;\r
+                                       a |= ((ch - _T('a'))&0xF) + 10;         \r
                                \r
-                               a =a<<4;\r
                        }\r
                        m_hash[i]=a;\r
                }\r
@@ -64,7 +65,7 @@ public:
                CString a;\r
                for(int i=0;i<GIT_HASH_SIZE;i++)\r
                {\r
-                       a.Format(_T("%02X"),m_hash[i]);\r
+                       a.Format(_T("%02x"),m_hash[i]);\r
                        str+=a;\r
                }\r
                return str;\r
@@ -90,6 +91,10 @@ public:
                return memcmp(left.m_hash, right.m_hash, GIT_HASH_SIZE) > 0;\r
        }\r
 \r
+       friend bool operator != (const CGitHash& left, const CGitHash& right)\r
+       {\r
+               return memcmp(left.m_hash, right.m_hash, GIT_HASH_SIZE) != 0;\r
+       }\r
 #if defined(_MFC_VER)\r
        friend CArchive& AFXAPI operator<<(CArchive& ar, CGitHash& hash)\r
        {\r