[gitg/wip/commit] Implement staging files
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/commit] Implement staging files
- Date: Wed, 3 Jul 2013 16:53:33 +0000 (UTC)
commit a0ae3ed7f3b6a1a24d39242f4b32d47ee87bf50e
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Wed Jul 3 18:52:07 2013 +0200
Implement staging files
gitg/commit/gitg-commit.vala | 129 ++++++++++++++++++++++++++++++------------
1 files changed, 92 insertions(+), 37 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index ed6585a..eef620c 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -109,57 +109,112 @@ namespace GitgCommit
private delegate void StageUnstageCallback(Gitg.StageStatusFile f, int numclick);
- private void on_unstaged_activated(Gitg.StageStatusFile f, int numclick)
+ private void show_unstaged_diff(Gitg.StageStatusFile f)
{
- if (numclick == 1)
- {
- var stage = application.repository.stage;
+ var stage = application.repository.stage;
- stage.diff_workdir.begin(f, (obj, res) => {
- try
- {
- var d = stage.diff_workdir.end(res);
+ stage.diff_workdir.begin(f, (obj, res) => {
+ try
+ {
+ var d = stage.diff_workdir.end(res);
- d_main.diff_view.unstaged = true;
- d_main.diff_view.staged = false;
+ d_main.diff_view.unstaged = true;
+ d_main.diff_view.staged = false;
- d_main.diff_view.diff = d;
- }
- catch
- {
- // TODO: error reporting
- d_main.diff_view.diff = null;
- }
- });
+ d_main.diff_view.diff = d;
+ }
+ catch
+ {
+ // TODO: show error in diff
+ d_main.diff_view.diff = null;
+ }
+ });
+ }
+
+ private void stage_file(Gitg.StageStatusFile f)
+ {
+ var stage = application.repository.stage;
+
+ stage.stage_path.begin(f.path, (obj, res) => {
+ try
+ {
+ stage.stage_path.end(res);
+ }
+ catch (Error e)
+ {
+ var msg = _("Failed to stage the file `%s'").printf(f.path);
+ application.show_infobar(msg, e.message, Gtk.MessageType.ERROR);
+ }
+
+ reload();
+ });
+ }
+
+ private void delete_file(Gitg.StageStatusFile f)
+ {
+ var stage = application.repository.stage;
+
+ stage.delete_path.begin(f.path, (obj, res) => {
+ try
+ {
+ stage.delete_path.end(res);
+ }
+ catch (Error e)
+ {
+ var msg = _("Failed to stage the removal of file
`%s'").printf(f.path);
+ application.show_infobar(msg, e.message, Gtk.MessageType.ERROR);
+ }
+
+ reload();
+ });
+ }
+
+ private void on_unstaged_activated(Gitg.StageStatusFile f, int numclick)
+ {
+ if (numclick == 1)
+ {
+ show_unstaged_diff(f);
}
else
{
- // Stage the whole file
+ if ((f.flags & Ggit.StatusFlags.WORKING_TREE_DELETED) != 0)
+ {
+ delete_file(f);
+ }
+ else
+ {
+ stage_file(f);
+ }
}
}
- private void on_staged_activated(Gitg.StageStatusFile f, int numclick)
+ private void show_staged_diff(Gitg.StageStatusFile f)
{
- if (numclick == 1)
- {
- var stage = application.repository.stage;
+ var stage = application.repository.stage;
- stage.diff_index.begin(f, (obj, res) => {
- try
- {
- var d = stage.diff_index.end(res);
+ stage.diff_index.begin(f, (obj, res) => {
+ try
+ {
+ var d = stage.diff_index.end(res);
- d_main.diff_view.unstaged = false;
- d_main.diff_view.staged = true;
+ d_main.diff_view.unstaged = false;
+ d_main.diff_view.staged = true;
- d_main.diff_view.diff = d;
- }
- catch
- {
- // TODO: error reporting
- d_main.diff_view.diff = null;
- }
- });
+ d_main.diff_view.diff = d;
+ }
+ catch
+ {
+ // TODO: error reporting
+ d_main.diff_view.diff = null;
+ }
+ });
+ }
+
+ private void on_staged_activated(Gitg.StageStatusFile f, int numclick)
+ {
+ if (numclick == 1)
+ {
+ show_staged_diff(f);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]