[gitg/vala] Properly resolve tag objects that point to commits
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Properly resolve tag objects that point to commits
- Date: Fri, 6 Jul 2012 17:37:45 +0000 (UTC)
commit 6a2410aaddffd515745609c1e1213fe599653db8
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Fri Jul 6 19:36:47 2012 +0200
Properly resolve tag objects that point to commits
libgitg/gitg-repository.vala | 61 +++++++++++++++++++++++++++----------
plugins/history/gitg-history.vala | 32 ++++++++++++++++----
2 files changed, 71 insertions(+), 22 deletions(-)
---
diff --git a/libgitg/gitg-repository.vala b/libgitg/gitg-repository.vala
index 60a223d..5b72805 100644
--- a/libgitg/gitg-repository.vala
+++ b/libgitg/gitg-repository.vala
@@ -32,6 +32,28 @@ public class Repository : Ggit.Repository
((Initable)this).init(null);
}
+ private void ensure_refs_add(Ggit.OId? id, Gitg.Ref r)
+ {
+ if (id == null)
+ {
+ return;
+ }
+
+ unowned SList<Gitg.Ref> refs;
+
+ if (d_refs.lookup_extended(id, null, out refs))
+ {
+ refs.append(r);
+ }
+ else
+ {
+ SList<Gitg.Ref> nrefs = new SList<Gitg.Ref>();
+ nrefs.append(r);
+
+ d_refs.insert(id, (owned)nrefs);
+ }
+ }
+
private void ensure_refs()
{
if (d_refs != null)
@@ -53,27 +75,34 @@ public class Repository : Ggit.Repository
}
catch { return 0; }
- if (r != null)
+ if (r == null)
+ {
+ return 0;
+ }
+
+ Ggit.OId? id = r.get_id();
+
+ if (id == null)
+ {
+ return 0;
+ }
+
+ ensure_refs_add(id, r);
+
+ // if it's a 'real' tag, then we are also going to store
+ // a ref to the underlying commit the tag points to
+ try
{
- Ggit.OId? id = r.get_id();
+ var tag = lookup(id, typeof(Ggit.Tag)) as Ggit.Tag;
+
+ // get the target id
+ id = tag.get_target_id();
if (id != null)
{
- unowned SList<Gitg.Ref> refs;
-
- if (d_refs.lookup_extended(id, null, out refs))
- {
- refs.append(r);
- }
- else
- {
- SList<Gitg.Ref> nrefs = new SList<Gitg.Ref>();
- nrefs.append(r);
-
- d_refs.insert(id, (owned)nrefs);
- }
+ ensure_refs_add(id, r);
}
- }
+ } catch {}
return 0;
});
diff --git a/plugins/history/gitg-history.vala b/plugins/history/gitg-history.vala
index 10b0d2b..c840b5b 100644
--- a/plugins/history/gitg-history.vala
+++ b/plugins/history/gitg-history.vala
@@ -110,21 +110,41 @@ namespace GitgHistory
d_main = ret["scrolled_window_commit_list"] as Gtk.Widget;
}
- private void update_walker(Ggit.Ref? head)
+ private void update_walker(Gitg.Ref? head)
{
- Ggit.Ref? th = head;
+ Ggit.OId? id = null;
- if (th == null && application.repository != null)
+ if (head != null && head.parsed_name.rtype == Gitg.RefType.TAG)
{
+ // See to resolve to the commit
try
{
- th = application.repository.get_head();
+ var t = application.repository.lookup(head.get_id(), typeof(Ggit.Tag)) as Ggit.Tag;
+
+ id = t.get_target_id();
+ } catch {}
+ }
+ else if (head != null)
+ {
+ id = head.get_id();
+ }
+
+ if (id == null && application.repository != null)
+ {
+ try
+ {
+ Gitg.Ref? th = application.repository.get_head();
+
+ if (th != null)
+ {
+ id = th.get_id();
+ }
} catch {}
}
- if (th != null)
+ if (id != null)
{
- d_model.set_include(new Ggit.OId[] { th.get_id() });
+ d_model.set_include(new Ggit.OId[] { id });
}
d_model.reload();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]