[gitg] Update commit for new Diff API



commit c918ad7f1d280e1b1860be8d808ace74127cf0fc
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Nov 23 15:07:58 2013 +0100

    Update commit for new Diff API

 gitg/commit/gitg-commit-dialog.vala |   27 ++++++++++++------------
 gitg/commit/gitg-commit.vala        |   38 +++++++++++++++++-----------------
 2 files changed, 33 insertions(+), 32 deletions(-)
---
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index 60e5963..fc587cf 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -82,12 +82,12 @@ class Dialog : Gtk.Dialog
        private bool d_enable_spell_checking;
        private string? d_spell_checking_language;
        private GtkSpell.Checker? d_spell_checker;
-       private Ggit.DiffList d_diff_list;
+       private Ggit.Diff d_diff;
 
-       public Ggit.DiffList? diff_list
+       public Ggit.Diff? diff
        {
-               owned get { return d_diff_list; }
-               construct set { d_diff_list = value; }
+               owned get { return d_diff; }
+               construct set { d_diff = value; }
        }
 
        public int max_visible_stat_items
@@ -413,9 +413,9 @@ class Dialog : Gtk.Dialog
 
                init_message_area();
 
-               if (diff_list != null)
+               if (diff != null)
                {
-                       iterate_diff_list();
+                       iterate_diff();
                }
                else
                {
@@ -425,19 +425,18 @@ class Dialog : Gtk.Dialog
        private Gtk.TextTag d_subject_tag;
        private Gtk.TextTag d_too_long_tag;
 
-       private void iterate_diff_list()
+       private void iterate_diff()
        {
-               var n = diff_list.get_num_deltas();
+               var n = diff.get_num_deltas();
                int num = 0;
 
                for (var i = 0; i < n; ++i)
                {
-                       Ggit.DiffDelta delta;
-                       Ggit.DiffPatch patch;
+                       Ggit.Patch patch;
 
                        try
                        {
-                               diff_list.get_patch(i, out patch, out delta);
+                               patch = new Ggit.Patch.from_diff(diff, i);
                        } catch { continue; }
 
                        size_t add;
@@ -448,6 +447,8 @@ class Dialog : Gtk.Dialog
                                patch.get_line_stats(null, out add, out remove);
                        } catch { continue; }
 
+                       var delta = patch.get_delta();
+
                        var nf = delta.get_new_file();
                        var path = nf.get_path();
 
@@ -652,9 +653,9 @@ class Dialog : Gtk.Dialog
        }
 
        public Dialog(Ggit.Signature author,
-                     Ggit.DiffList? diff_list)
+                     Ggit.Diff?     diff)
        {
-               Object(author: author, diff_list: diff_list);
+               Object(author: author, diff: diff);
        }
 
        private void update_font_settings()
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index b77888a..4bd835f 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -502,9 +502,9 @@ namespace GitgCommit
                        return retval;
                }
 
-               private async Ggit.DiffList? index_diff_list()
+               private async Ggit.Diff? index_diff()
                {
-                       var opts = new Ggit.DiffOptions(Ggit.DiffOption.INCLUDE_UNTRACKED_CONTENT |
+                       var opts = new Ggit.DiffOptions(Ggit.DiffOption.INCLUDE_UNTRACKED |
                                                        Ggit.DiffOption.DISABLE_PATHSPEC_MATCH |
                                                        Ggit.DiffOption.RECURSE_UNTRACKED_DIRS,
                                                        3,
@@ -523,43 +523,43 @@ namespace GitgCommit
                        }
                        catch { return null; }
 
-                       Ggit.DiffList? diff_list = null;
+                       Ggit.Diff? diff = null;
 
                        try
                        {
                                var index = application.repository.get_index();
 
                                yield Gitg.Async.thread(() => {
-                                       diff_list = new Ggit.DiffList.tree_to_index(application.repository,
-                                                                                   tree,
-                                                                                   index,
-                                                                                   opts);
+                                       diff = new Ggit.Diff.tree_to_index(application.repository,
+                                                                          tree,
+                                                                          index,
+                                                                          opts);
                                });
                        } catch { return null; }
 
-                       return diff_list;
+                       return diff;
                }
 
                private void run_commit_dialog(bool           skip_hooks,
                                               Ggit.Signature author,
                                               Ggit.Signature committer)
                {
-                       index_diff_list.begin((obj, res) => {
-                               var diff_list = index_diff_list.end(res);
+                       index_diff.begin((obj, res) => {
+                               var diff = index_diff.end(res);
 
-                               run_commit_dialog_with_diff_list(skip_hooks,
-                                                                author,
-                                                                committer,
-                                                                diff_list);
+                               run_commit_dialog_with_diff(skip_hooks,
+                                                           author,
+                                                           committer,
+                                                           diff);
                        });
                }
 
-               private void run_commit_dialog_with_diff_list(bool skip_hooks,
-                                                             Ggit.Signature author,
-                                                             Ggit.Signature committer,
-                                                             Ggit.DiffList? diff_list)
+               private void run_commit_dialog_with_diff(bool           skip_hooks,
+                                                        Ggit.Signature author,
+                                                        Ggit.Signature committer,
+                                                        Ggit.Diff?     diff)
                {
-                       var dlg = new Dialog(author, diff_list);
+                       var dlg = new Dialog(author, diff);
 
                        dlg.set_transient_for((Gtk.Window)d_main.get_toplevel());
                        dlg.set_default_response(Gtk.ResponseType.OK);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]