[gitg] Set message of HEAD when toggling amend option active



commit 64c16424b3ada06b4926b2555ce2383263a658e9
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jul 6 12:05:17 2013 +0200

    Set message of HEAD when toggling amend option active

 gitg/commit/gitg-commit.vala |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index a5f0691..36a4006 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -472,6 +472,25 @@ namespace GitgCommit
                        return true;
                }
 
+               private async string? get_head_message()
+               {
+                       string? retval = null;
+
+                       yield Gitg.Async.thread(() => {
+                               var repo = application.repository;
+
+                               try
+                               {
+                                       var head = repo.get_head();
+                                       var commit = repo.lookup<Ggit.Commit>(head.get_target());
+
+                                       retval = commit.get_message();
+                               } catch {}
+                       });
+
+                       return retval;
+               }
+
                private void run_commit_dialog(bool           skip_hooks,
                                               Ggit.Signature author,
                                               Ggit.Signature committer)
@@ -492,6 +511,20 @@ namespace GitgCommit
                                }
                        });
 
+                       dlg.notify["amend"].connect((obj, pspec) => {
+                               if (dlg.message.strip() == "")
+                               {
+                                       get_head_message.begin((obj, res) => {
+                                               string? message = get_head_message.end(res);
+
+                                               if (message != null && dlg.message.strip() == "")
+                                               {
+                                                       dlg.message = message;
+                                               }
+                                       });
+                               }
+                       });
+
                        dlg.show();
                }
 



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