1
From fe3f3b36f4b15d7c43368f28f7817b84829bedaf Mon Sep 17 00:00:00 2001
2
From: Jonny Lamb <jonny@debian.org>
3
Date: Tue, 24 Mar 2009 19:31:14 +0000
4
Subject: [PATCH 2/2] Initial patch to show tags referenced from tag objects.
6
Signed-off-by: Jonny Lamb <jonny@debian.org>
8
gitg/gitg-ref.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
9
gitg/gitg-ref.h | 4 +++-
10
gitg/gitg-repository.c | 2 +-
11
gitg/gitg-repository.h | 3 ++-
12
4 files changed, 48 insertions(+), 4 deletions(-)
14
diff --git a/gitg/gitg-ref.c b/gitg/gitg-ref.c
15
index f681893..81d71fb 100644
18
@@ -30,8 +30,46 @@ typedef struct
23
+set_commit_hash(GitgRef *ref, GitgRepository *repo, gchar *sha1)
25
+ gchar **out = gitg_repository_command_with_outputv (repo, NULL, "cat-file", "tag", sha1, NULL);
27
+ if (out != NULL && g_str_has_prefix (*out, "object"))
29
+ gchar **components = g_strsplit(*out, " ", 2);
31
+ if (g_strv_length(components) == 2)
33
+ gitg_utils_sha1_to_hash(components[1], ref->hash);
36
+ g_strfreev (components);
43
+find_tag_ref(GitgRef *ref, GitgRepository *repo)
45
+ gchar *sha1 = gitg_utils_hash_to_sha1_new(ref->hash);
46
+ gchar **out = gitg_repository_command_with_outputv (repo, NULL, "cat-file", "-t", sha1, NULL);
48
+ if (out != NULL && g_strv_length (out) == 1)
50
+ if (g_strcmp0 (*out, "tag") == 0)
52
+ set_commit_hash (ref, repo, sha1);
61
-gitg_ref_new(gchar const *hash, gchar const *name)
62
+gitg_ref_new(GitgRepository *repo, gchar const *hash, gchar const *name)
64
GitgRef *inst = g_slice_new0(GitgRef);
66
@@ -61,6 +99,9 @@ gitg_ref_new(gchar const *hash, gchar const *name)
67
inst->type = GITG_REF_TYPE_NONE;
68
inst->shortname = g_strdup(name);
71
+ if (inst->type == GITG_REF_TYPE_TAG)
72
+ find_tag_ref (inst, repo);
76
diff --git a/gitg/gitg-ref.h b/gitg/gitg-ref.h
77
index 32adae7..3d5ae01 100644
80
@@ -41,7 +41,9 @@ typedef struct
84
-GitgRef *gitg_ref_new(gchar const *hash, gchar const *name);
85
+#include "gitg-repository.h"
87
+GitgRef *gitg_ref_new(GitgRepository *repo, gchar const *hash, gchar const *name);
88
void gitg_ref_free(GitgRef *ref);
89
GitgRef *gitg_ref_copy(GitgRef *ref);
91
diff --git a/gitg/gitg-repository.c b/gitg/gitg-repository.c
92
index f7b9a64..2b88459 100644
93
--- a/gitg/gitg-repository.c
94
+++ b/gitg/gitg-repository.c
95
@@ -639,7 +639,7 @@ gitg_repository_get_loader(GitgRepository *self)
97
add_ref(GitgRepository *self, gchar const *sha1, gchar const *name)
99
- GitgRef *ref = gitg_ref_new(sha1, name);
100
+ GitgRef *ref = gitg_ref_new(self, sha1, name);
101
GSList *refs = (GSList *)g_hash_table_lookup(self->priv->refs, ref->hash);
104
diff --git a/gitg/gitg-repository.h b/gitg/gitg-repository.h
105
index 4fc5eb5..3262d5a 100644
106
--- a/gitg/gitg-repository.h
107
+++ b/gitg/gitg-repository.h
110
#include "gitg-revision.h"
111
#include "gitg-runner.h"
112
-#include "gitg-ref.h"
116
@@ -62,6 +61,8 @@ struct _GitgRepositoryClass
117
void (*load) (GitgRepository *);
120
+#include "gitg-ref.h"
122
GType gitg_repository_get_type (void) G_GNUC_CONST;
123
GitgRepository *gitg_repository_new(gchar const *path);
124
gchar const *gitg_repository_get_path(GitgRepository *repository);