[gitg] Factor out get_diff method
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Factor out get_diff method
- Date: Thu, 21 Feb 2013 16:41:46 +0000 (UTC)
commit cba6d104ca71d885c013d7eb1868ce461d8d1f66
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Feb 21 17:41:25 2013 +0100
Factor out get_diff method
libgitg-gtk/gitg-gtk-diff-view.vala | 37 ++-------------------------------
libgitg/gitg-commit.vala | 38 +++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 34 deletions(-)
---
diff --git a/libgitg-gtk/gitg-gtk-diff-view.vala b/libgitg-gtk/gitg-gtk-diff-view.vala
index f97974a..fd553c4 100644
--- a/libgitg-gtk/gitg-gtk-diff-view.vala
+++ b/libgitg-gtk/gitg-gtk-diff-view.vala
@@ -22,7 +22,7 @@ namespace GitgGtk
public class DiffView : WebKit.WebView
{
private Ggit.Diff? d_diff;
- private Ggit.Commit? d_commit;
+ private Gitg.Commit? d_commit;
private Settings d_fontsettings;
private static Gee.HashMap<string, GitgGtk.DiffView> s_diffmap;
@@ -47,7 +47,7 @@ namespace GitgGtk
}
}
- public Ggit.Commit? commit
+ public Gitg.Commit? commit
{
get { return d_commit; }
set
@@ -258,38 +258,7 @@ namespace GitgGtk
if (d_commit != null)
{
- d_diff = null;
-
- var repo = d_commit.get_owner();
-
- try
- {
- var parents = d_commit.get_parents();
-
- // Create a new diff from the parents to the commit tree
- for (var i = 0; i < parents.size(); ++i)
- {
- var parent = parents.get(0);
-
- if (i == 0)
- {
- d_diff = new Ggit.Diff.tree_to_tree(repo,
- parent.get_tree(),
-
d_commit.get_tree(),
- options);
- }
- else
- {
- var d = new Ggit.Diff.tree_to_tree(repo,
- parent.get_tree(),
-
d_commit.get_tree(),
- options);
-
- d_diff.merge(d);
- }
- }
- }
- catch {}
+ d_diff = d_commit.get_diff(options);
}
if (d_diff != null)
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 569d315..79de9e8 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -113,6 +113,44 @@ public class Commit : Ggit.Commit
return date_for_display(get_author().get_time());
}
}
+
+ public Ggit.Diff get_diff(Ggit.DiffOptions? options)
+ {
+ Ggit.Diff? diff = null;
+
+ var repo = get_owner();
+
+ try
+ {
+ var parents = get_parents();
+
+ // Create a new diff from the parents to the commit tree
+ for (var i = 0; i < parents.size(); ++i)
+ {
+ var parent = parents.get(0);
+
+ if (i == 0)
+ {
+ diff = new Ggit.Diff.tree_to_tree(repo,
+ parent.get_tree(),
+ get_tree(),
+ options);
+ }
+ else
+ {
+ var d = new Ggit.Diff.tree_to_tree(repo,
+ parent.get_tree(),
+ get_tree(),
+ options);
+
+ diff.merge(d);
+ }
+ }
+ }
+ catch {}
+
+ return diff;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]