[gitg] Add committer info
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add committer info
- Date: Sun, 6 Jun 2010 22:14:39 +0000 (UTC)
commit 868baebdc4f88794a70d1e5bf70abd043dae0d2d
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Mon Jun 7 00:14:31 2010 +0200
Add committer info
gitg/gitg-revision-details-panel.c | 40 +++++++++---
gitg/gitg-revision-details-panel.ui | 124 +++++++++++++++++-----------------
libgitg/gitg-repository.c | 50 +++++++++-----
libgitg/gitg-revision.c | 94 ++++++++++++++++++++++-----
libgitg/gitg-revision.h | 53 ++++++++++-----
5 files changed, 237 insertions(+), 124 deletions(-)
---
diff --git a/gitg/gitg-revision-details-panel.c b/gitg/gitg-revision-details-panel.c
index b3655b4..67c17d7 100644
--- a/gitg/gitg-revision-details-panel.c
+++ b/gitg/gitg-revision-details-panel.c
@@ -42,7 +42,7 @@ struct _GitgRevisionDetailsPanelPrivate
{
GtkLabel *sha;
GtkLabel *author;
- GtkLabel *date;
+ GtkLabel *committer;
GtkLabel *subject;
GtkTable *parents;
@@ -120,7 +120,7 @@ initialize_ui (GitgRevisionDetailsPanel *panel)
priv->sha = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_sha"));
priv->author = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_author"));
- priv->date = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_date"));
+ priv->committer = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_committer"));
priv->subject = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_subject"));
priv->parents = GTK_TABLE (gtk_builder_get_object (priv->builder, "table_parents"));
priv->text_view = GTK_TEXT_VIEW (gtk_builder_get_object (priv->builder, "text_view_details"));
@@ -128,8 +128,8 @@ initialize_ui (GitgRevisionDetailsPanel *panel)
gchar const *lbls[] = {
"label_subject_lbl",
"label_author_lbl",
+ "label_committer_lbl",
"label_sha_lbl",
- "label_date_lbl",
"label_parent_lbl"
};
@@ -677,8 +677,32 @@ reload (GitgRevisionDetailsPanel *panel)
// Update labels
if (panel->priv->revision)
{
- gtk_label_set_text (panel->priv->author,
- gitg_revision_get_author (panel->priv->revision));
+ gchar *tmp;
+ gchar *date;
+
+ date = gitg_revision_get_author_date_for_display (panel->priv->revision);
+ tmp = g_markup_printf_escaped ("<a href='mailto:%s'>%s <%s></a> (%s)",
+ gitg_revision_get_author_email (panel->priv->revision),
+ gitg_revision_get_author (panel->priv->revision),
+ gitg_revision_get_author_email (panel->priv->revision),
+ date);
+
+ gtk_label_set_markup (panel->priv->author, tmp);
+
+ g_free (tmp);
+ g_free (date);
+
+ date = gitg_revision_get_committer_date_for_display (panel->priv->revision);
+ tmp = g_markup_printf_escaped ("<a href='mailto:%s'>%s <%s></a> (%s)",
+ gitg_revision_get_committer_email (panel->priv->revision),
+ gitg_revision_get_committer (panel->priv->revision),
+ gitg_revision_get_committer_email (panel->priv->revision),
+ date);
+
+ gtk_label_set_markup (panel->priv->committer, tmp);
+
+ g_free (tmp);
+ g_free (date);
gchar *subject;
@@ -688,10 +712,6 @@ reload (GitgRevisionDetailsPanel *panel)
gtk_label_set_markup (panel->priv->subject, subject);
g_free (subject);
- gchar *date = gitg_revision_get_timestamp_for_display (panel->priv->revision);
- gtk_label_set_text (panel->priv->date, date);
- g_free (date);
-
gchar *sha = gitg_revision_get_sha1 (panel->priv->revision);
gtk_label_set_text (panel->priv->sha, sha);
@@ -703,8 +723,8 @@ reload (GitgRevisionDetailsPanel *panel)
else
{
gtk_label_set_text (panel->priv->author, "");
+ gtk_label_set_text (panel->priv->committer, "");
gtk_label_set_text (panel->priv->subject, "");
- gtk_label_set_text (panel->priv->date, "");
gtk_label_set_text (panel->priv->sha, "");
}
diff --git a/gitg/gitg-revision-details-panel.ui b/gitg/gitg-revision-details-panel.ui
index 103d7b0..13805c2 100644
--- a/gitg/gitg-revision-details-panel.ui
+++ b/gitg/gitg-revision-details-panel.ui
@@ -13,42 +13,21 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkTable" id="table_parents">
- <property name="visible">True</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">3</property>
- <property name="row_spacing">2</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_subject">
+ <object class="GtkLabel" id="label_author">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
- <property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_date">
+ <object class="GtkLabel" id="label_sha">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="use_markup">True</property>
@@ -57,98 +36,119 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_author">
+ <object class="GtkLabel" id="label_author_lbl">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="use_markup">True</property>
- <property name="selectable">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Author:</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_sha">
+ <object class="GtkLabel" id="label_sha_lbl">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">SHA:</property>
<property name="use_markup">True</property>
- <property name="selectable">True</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_parent_lbl">
+ <object class="GtkLabel" id="label_committer_lbl">
<property name="visible">True</property>
<property name="xalign">1</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Parent:</property>
+ <property name="label" translatable="yes">Committer:</property>
</object>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_subject_lbl">
+ <object class="GtkLabel" id="label_committer">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Subject:</property>
+ <property name="xalign">0</property>
+ <property name="use_markup">True</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_subject">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="use_markup">True</property>
+ <property name="selectable">True</property>
+ <property name="ellipsize">end</property>
</object>
<packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_date_lbl">
+ <object class="GtkLabel" id="label_subject_lbl">
<property name="visible">True</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">Date:</property>
+ <property name="label" translatable="yes">Subject:</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_author_lbl">
+ <object class="GtkTable" id="table_parents">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Author:</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_sha_lbl">
+ <object class="GtkLabel" id="label_parent_lbl">
<property name="visible">True</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">SHA:</property>
- <property name="use_markup">True</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Parent:</property>
</object>
<packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
diff --git a/libgitg/gitg-repository.c b/libgitg/gitg-repository.c
index 669655f..3d4b1cd 100644
--- a/libgitg/gitg-repository.c
+++ b/libgitg/gitg-repository.c
@@ -244,7 +244,7 @@ tree_model_get_value (GtkTreeModel *tree_model,
g_value_set_string (value, gitg_revision_get_author (rv));
break;
case DATE_COLUMN:
- g_value_take_string (value, gitg_revision_get_timestamp_for_display (rv));
+ g_value_take_string (value, gitg_revision_get_author_date_for_display (rv));
break;
default:
g_assert_not_reached ();
@@ -889,9 +889,13 @@ add_dummy_commit (GitgRepository *repository,
revision = gitg_revision_new ("0000000000000000000000000000000000000000",
"",
+ "",
+ tv.tv_sec,
+ "",
+ "",
+ -1,
subject,
- NULL,
- tv.tv_sec);
+ NULL);
gitg_revision_set_sign (revision, staged ? 't' : 'u');
append_revision (repository, revision);
@@ -1030,19 +1034,26 @@ loader_update_stash (GitgRepository *repository,
gchar **components = g_strsplit (line, "\01", 0);
guint len = g_strv_length (components);
- if (len < 4)
+ if (len < 5)
{
g_strfreev (components);
continue;
}
- /* components -> [hash, author, subject, timestamp] */
- gint64 timestamp = g_ascii_strtoll (components[3], NULL, 0);
+ /* components -> [hash, author, author email, author date,
+ committer, committer email, committer date,
+ subject, parents, left-right] */
+ gint64 author_date = g_ascii_strtoll (components[3], NULL, 0);
+
GitgRevision *rv = gitg_revision_new (components[0],
components[1],
components[2],
+ author_date,
+ NULL,
NULL,
- timestamp);
+ -1,
+ components[4],
+ NULL);
add_ref (repository, components[0], "refs/stash");
@@ -1064,24 +1075,29 @@ loader_update_commits (GitgRepository *self,
gchar **components = g_strsplit (line, "\01", 0);
guint len = g_strv_length (components);
- if (len < 5)
+ if (len < 9)
{
g_strfreev (components);
continue;
}
/* components -> [hash, author, subject, parents ([1 2 3]), timestamp[, leftright]] */
- gint64 timestamp = g_ascii_strtoll (components[4], NULL, 0);
+ gint64 author_date = g_ascii_strtoll (components[3], NULL, 0);
+ gint64 committer_date = g_ascii_strtoll (components[6], NULL, 0);
GitgRevision *rv = gitg_revision_new (components[0],
components[1],
components[2],
- components[3],
- timestamp);
-
- if (len > 5 && strlen (components[5]) == 1 && strchr ("<>-^", *components[5]) != NULL)
+ author_date,
+ components[4],
+ components[5],
+ committer_date,
+ components[7],
+ components[8]);
+
+ if (len > 9 && strlen (components[9]) == 1 && strchr ("<>-^", *components[9]) != NULL)
{
- gitg_revision_set_sign (rv, *components[5]);
+ gitg_revision_set_sign (rv, *components[9]);
}
append_revision (self, rv);
@@ -1203,11 +1219,11 @@ build_log_args (GitgRepository *self,
if (has_left_right (av, argc))
{
- argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at\x01%m");
+ argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%ae\x01%at\x01%cn\x01%ce\x01%ct\x01%s\x01%P\x01%m");
}
else
{
- argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%s\x01%P\x01%at");
+ argv[1] = g_strdup ("--pretty=format:%H\x01%an\x01%ae\x01%at\x01%cn\x01%ce\x01%ct\x01%s\x01%P");
}
argv[2] = g_strdup ("--encoding=UTF-8");
@@ -1370,7 +1386,7 @@ reload_revisions (GitgRepository *repository,
repository->priv->loader,
error,
"log",
- "--pretty=format:%H\x01%an\x01%s\x01%at",
+ "--pretty=format:%H\x01%an\x01%ae\x01%at\x01%s",
"--encoding=UTF-8",
"-g",
"refs/stash",
diff --git a/libgitg/gitg-revision.c b/libgitg/gitg-revision.c
index 5c0b9f9..d4bbbae 100644
--- a/libgitg/gitg-revision.c
+++ b/libgitg/gitg-revision.c
@@ -31,6 +31,13 @@ struct _GitgRevision
GitgHash hash;
gchar *author;
+ gchar *author_email;
+ gint64 author_date;
+
+ gchar *committer;
+ gchar *committer_email;
+ gint64 committer_date;
+
gchar *subject;
GitgHash *parents;
@@ -39,8 +46,6 @@ struct _GitgRevision
GSList *lanes;
gint8 mylane;
-
- gint64 timestamp;
};
static void
@@ -55,6 +60,11 @@ static void
gitg_revision_finalize (GitgRevision *revision)
{
g_free (revision->author);
+ g_free (revision->author_email);
+
+ g_free (revision->committer);
+ g_free (revision->committer_email);
+
g_free (revision->subject);
g_free (revision->parents);
@@ -91,20 +101,32 @@ gitg_revision_unref (GitgRevision *revision)
gitg_revision_finalize (revision);
}
-GitgRevision *gitg_revision_new (gchar const *sha,
- gchar const *author,
- gchar const *subject,
- gchar const *parents,
- gint64 timestamp)
+GitgRevision *
+gitg_revision_new (gchar const *sha,
+ gchar const *author,
+ gchar const *author_email,
+ gint64 author_date,
+ gchar const *committer,
+ gchar const *committer_email,
+ gint64 committer_date,
+ gchar const *subject,
+ gchar const *parents)
{
GitgRevision *rv = g_slice_new0 (GitgRevision);
rv->refcount = 1;
gitg_hash_sha1_to_hash (sha, rv->hash);
+
rv->author = g_strdup (author);
+ rv->author_email = g_strdup (author_email);
+ rv->author_date = author_date;
+
+ rv->committer = g_strdup (committer);
+ rv->committer_email = g_strdup (committer_email);
+ rv->committer_date = committer_date;
+
rv->subject = g_strdup (subject);
- rv->timestamp = timestamp;
if (parents)
{
@@ -133,15 +155,39 @@ gitg_revision_get_author (GitgRevision *revision)
}
gchar const *
-gitg_revision_get_subject (GitgRevision *revision)
+gitg_revision_get_author_email (GitgRevision *revision)
{
- return revision->subject;
+ return revision->author_email;
}
-guint64
-gitg_revision_get_timestamp (GitgRevision *revision)
+gint64
+gitg_revision_get_author_date (GitgRevision *revision)
+{
+ return revision->author_date;
+}
+
+gchar const *
+gitg_revision_get_committer (GitgRevision *revision)
{
- return revision->timestamp;
+ return revision->committer;
+}
+
+gchar const *
+gitg_revision_get_committer_email (GitgRevision *revision)
+{
+ return revision->committer_email;
+}
+
+gint64
+gitg_revision_get_committer_date (GitgRevision *revision)
+{
+ return revision->committer_date;
+}
+
+gchar const *
+gitg_revision_get_subject (GitgRevision *revision)
+{
+ return revision->subject;
}
gchar const *
@@ -336,14 +382,30 @@ gitg_revision_get_format_patch_name (GitgRevision *revision)
return ret;
}
-gchar *
-gitg_revision_get_timestamp_for_display (GitgRevision *revision)
+static gchar *
+date_for_display (gint64 date)
{
- time_t t = gitg_revision_get_timestamp (revision);
+ if (date < 0)
+ {
+ return g_strdup ("");
+ }
+ time_t t = date;
struct tm *tms = localtime (&t);
gchar buf[255];
strftime (buf, 254, "%c", tms);
return gitg_convert_utf8 (buf, -1);
}
+
+gchar *
+gitg_revision_get_author_date_for_display (GitgRevision *revision)
+{
+ return date_for_display (gitg_revision_get_author_date (revision));
+}
+
+gchar *
+gitg_revision_get_committer_date_for_display (GitgRevision *revision)
+{
+ return date_for_display (gitg_revision_get_committer_date (revision));
+}
diff --git a/libgitg/gitg-revision.h b/libgitg/gitg-revision.h
index 35a954c..e01a141 100644
--- a/libgitg/gitg-revision.h
+++ b/libgitg/gitg-revision.h
@@ -36,37 +36,52 @@ typedef struct _GitgRevision GitgRevision;
GType gitg_revision_get_type (void) G_GNUC_CONST;
-GitgRevision *gitg_revision_new(gchar const *hash,
- gchar const *author, gchar const *subject, gchar const *parents, gint64 timestamp);
+GitgRevision *gitg_revision_new (gchar const *hash,
+ gchar const *author,
+ gchar const *author_email,
+ gint64 author_date,
+ gchar const *committer,
+ gchar const *committer_email,
+ gint64 committer_date,
+ gchar const *subject,
+ gchar const *parents);
-inline gchar const *gitg_revision_get_author(GitgRevision *revision);
-inline gchar const *gitg_revision_get_subject(GitgRevision *revision);
-inline guint64 gitg_revision_get_timestamp(GitgRevision *revision);
-inline gchar const *gitg_revision_get_hash(GitgRevision *revision);
-inline GitgHash *gitg_revision_get_parents_hash(GitgRevision *revision, guint *num_parents);
+inline gchar const *gitg_revision_get_author (GitgRevision *revision);
+inline gchar const *gitg_revision_get_author_email (GitgRevision *revision);
+inline gint64 gitg_revision_get_author_date (GitgRevision *revision);
-gchar *gitg_revision_get_sha1(GitgRevision *revision);
-gchar **gitg_revision_get_parents(GitgRevision *revision);
+inline gchar const *gitg_revision_get_committer (GitgRevision *revision);
+inline gchar const *gitg_revision_get_committer_email (GitgRevision *revision);
+inline gint64 gitg_revision_get_committer_date (GitgRevision *revision);
-GSList *gitg_revision_get_lanes(GitgRevision *revision);
-GitgLane *gitg_revision_get_lane(GitgRevision *revision);
-void gitg_revision_set_lanes(GitgRevision *revision, GSList *lanes, gint8 mylane);
+inline gchar const *gitg_revision_get_subject (GitgRevision *revision);
-GSList *gitg_revision_remove_lane(GitgRevision *revision, GitgLane *lane);
-GSList *gitg_revision_insert_lane(GitgRevision *revision, GitgLane *lane, gint index);
+inline gchar const *gitg_revision_get_hash (GitgRevision *revision);
+inline GitgHash *gitg_revision_get_parents_hash (GitgRevision *revision, guint *num_parents);
-gint8 gitg_revision_get_mylane(GitgRevision *revision);
-void gitg_revision_set_mylane(GitgRevision *revision, gint8 mylane);
+gchar *gitg_revision_get_sha1 (GitgRevision *revision);
+gchar **gitg_revision_get_parents (GitgRevision *revision);
+
+GSList *gitg_revision_get_lanes (GitgRevision *revision);
+GitgLane *gitg_revision_get_lane (GitgRevision *revision);
+void gitg_revision_set_lanes (GitgRevision *revision, GSList *lanes, gint8 mylane);
+
+GSList *gitg_revision_remove_lane (GitgRevision *revision, GitgLane *lane);
+GSList *gitg_revision_insert_lane (GitgRevision *revision, GitgLane *lane, gint index);
+
+gint8 gitg_revision_get_mylane (GitgRevision *revision);
+void gitg_revision_set_mylane (GitgRevision *revision, gint8 mylane);
void gitg_revision_set_sign(GitgRevision *revision, char sign);
char gitg_revision_get_sign(GitgRevision *revision);
-GitgRevision *gitg_revision_ref(GitgRevision *revision);
-void gitg_revision_unref(GitgRevision *revision);
+GitgRevision *gitg_revision_ref (GitgRevision *revision);
+void gitg_revision_unref (GitgRevision *revision);
gchar *gitg_revision_get_format_patch_name (GitgRevision *revision);
-gchar *gitg_revision_get_timestamp_for_display(GitgRevision *revision);
+gchar *gitg_revision_get_author_date_for_display (GitgRevision *revision);
+gchar *gitg_revision_get_committer_date_for_display (GitgRevision *revision);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]