OSDN Git Service

Fix file history wrong
[tortoisegit/TortoiseGitJp.git] / ext / gitdll / gitdll.c
index d609b07..0257738 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
@@ -250,9 +267,18 @@ char **strtoargv(char *arg, int *size)
        int count=0;\r
        char *p=arg;\r
        char **argv;\r
+       \r
        int i=0;\r
        while(*p)\r
        {\r
+               if(*p == '\\')\r
+                       *p='/';\r
+               p++;\r
+       }\r
+       p=arg;\r
+\r
+       while(*p)\r
+       {\r
                if(*p == ' ')\r
                        count ++;\r
                p++;\r
@@ -318,8 +344,7 @@ int git_open_log(GIT_LOG * handle, char * arg)
 \r
        init_revisions(p_Rev, g_prefix);\r
        p_Rev->diff = 1;\r
-       p_Rev->simplify_history = 0;\r
-       \r
+               \r
        cmd_log_init(argc, argv, g_prefix,p_Rev);\r
 \r
        p_Rev->pPrivate = argv;\r
@@ -332,6 +357,14 @@ int git_get_log_firstcommit(GIT_LOG handle)
        return prepare_revision_walk(handle);\r
 }\r
 \r
+int git_get_log_estimate_commit_count(GIT_LOG handle)\r
+{\r
+       struct rev_info *p_Rev;\r
+       p_Rev=(struct rev_info *)handle;\r
+\r
+       return estimate_commit_count(p_Rev, p_Rev->commits);\r
+}\r
+\r
 int git_get_log_nextcommit(GIT_LOG handle, GIT_COMMIT *commit)\r
 {\r
        int ret =0;\r
@@ -423,6 +456,38 @@ int git_diff_flush(GIT_DIFF diff)
 \r
        free_diffstat_info(&p_Rev->diffstat);\r
 }\r
+\r
+int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count)\r
+{\r
+       int ret;\r
+       struct rev_info *p_Rev;\r
+       int i;\r
+       struct diff_queue_struct *q = &diff_queued_diff;\r
+\r
+       p_Rev = (struct rev_info *)diff;\r
+\r
+       ret=diff_root_tree_sha1(hash, "", &p_Rev->diffopt);\r
+\r
+       if(ret)\r
+               return ret;\r
+\r
+       diffcore_std(&p_Rev->diffopt);\r
+\r
+       memset(&p_Rev->diffstat, 0, sizeof(struct diffstat_t));\r
+       for (i = 0; i < q->nr; i++) {\r
+               struct diff_filepair *p = q->queue[i];\r
+               //if (check_pair_status(p))\r
+               diff_flush_stat(p, &p_Rev->diffopt, &p_Rev->diffstat);\r
+       }\r
+\r
+       if(file)\r
+               *file = q;\r
+       if(count)\r
+               *count = q->nr;\r
+\r
+       return 0;\r
+}\r
+\r
 int git_diff(GIT_DIFF diff, GIT_HASH hash1, GIT_HASH hash2, GIT_FILE * file, int *count)\r
 {\r
        struct rev_info *p_Rev;\r
@@ -465,10 +530,10 @@ int git_get_diff_file(GIT_DIFF diff,GIT_FILE file,int i, char **newname, char **
                return -1;\r
 \r
        if(newname)\r
-               *newname = q->queue[i]->one->path;\r
+               *newname = q->queue[i]->two->path;\r
 \r
        if(oldname)\r
-               *oldname = q->queue[i]->two->path;\r
+               *oldname = q->queue[i]->one->path;\r
 \r
        if(status)\r
                *status = q->queue[i]->status;\r