From e7be57b4d2abd68d594d41a6d42575a8bf2f2a3c Mon Sep 17 00:00:00 2001 From: Frank Li Date: Thu, 30 Sep 2010 10:40:58 +0800 Subject: [PATCH] Fixed issue #571: missing annotated tags display in log dialog Signed-off-by: Frank Li --- ext/gitdll/gitdll.c | 21 +++++++++++++++++++++ ext/gitdll/gitdll.h | 2 +- src/Git/Git.cpp | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ext/gitdll/gitdll.c b/ext/gitdll/gitdll.c index 2ef239025..bdc8211ef 100644 --- a/ext/gitdll/gitdll.c +++ b/ext/gitdll/gitdll.c @@ -846,4 +846,25 @@ const char *git_resolve_ref(const char *ref, unsigned char *sha1, int reading, i int git_for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data) { return for_each_reflog_ent(ref,fn,cb_data); +} + +int git_deref_tag(unsigned char *tagsha1, GIT_HASH refhash) +{ + struct object *obj = NULL; + obj = parse_object(tagsha1); + if (!obj) + return -1; + + if (obj->type == OBJ_TAG) + { + obj = deref_tag(obj, "", 0); + if (!obj) + return -1; + + memcpy(refhash, obj->sha1, sizeof(GIT_HASH)); + return 0; + } + + memcpy(refhash, tagsha1, sizeof(GIT_HASH)); + return 0; } \ No newline at end of file diff --git a/ext/gitdll/gitdll.h b/ext/gitdll/gitdll.h index 18ca280b4..d1ffedcda 100644 --- a/ext/gitdll/gitdll.h +++ b/ext/gitdll/gitdll.h @@ -163,5 +163,5 @@ GITDLL_API const char *git_resolve_ref(const char *path, unsigned char *sha1, in typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *); GITDLL_API int git_for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data); - +GITDLL_API int git_deref_tag(const unsigned char *tagsha1,GIT_HASH refhash); #endif \ No newline at end of file diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index e1e1dcc8b..8947a4b3e 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -868,6 +868,16 @@ int addto_map_each_ref_fn(const char *refname, const unsigned char *sha1, int fl CGitHash hash((char*)sha1); (*map)[hash].push_back(str); + + const char *hex = NULL; + if(strncmp(refname, "refs/tags", 9) == 0) + { + GIT_HASH refhash; + if(!git_deref_tag(sha1, refhash)) + { + (*map)[(char*)refhash].push_back(str); + } + } return 0; } -- 2.11.4.GIT