[gitg] Fix diff index against empty repository
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Fix diff index against empty repository
- Date: Wed, 17 Aug 2016 14:05:11 +0000 (UTC)
commit f9ecad6db99faf02f416821922bc8991f0b285eb
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Wed Aug 17 16:02:30 2016 +0200
Fix diff index against empty repository
https://bugzilla.gnome.org/show_bug.cgi?id=769996
gitg/commit/gitg-commit.vala | 15 ++++++++++-----
libgitg/gitg-stage.vala | 7 ++++++-
2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 5412adf..7b6d34a 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -1149,13 +1149,18 @@ namespace GitgCommit
opts.n_context_lines = 3;
opts.n_interhunk_lines = 3;
- var stage = application.repository.stage;
+ var repository = application.repository;
+
+ var stage = repository.stage;
- Ggit.Tree tree;
+ Ggit.Tree? tree = null;
try
{
- tree = yield stage.get_head_tree();
+ if (!repository.is_empty())
+ {
+ tree = yield stage.get_head_tree();
+ }
}
catch { return null; }
@@ -1163,10 +1168,10 @@ namespace GitgCommit
try
{
- var index = application.repository.get_index();
+ var index = repository.get_index();
yield Gitg.Async.thread(() => {
- diff = new Ggit.Diff.tree_to_index(application.repository,
+ diff = new Ggit.Diff.tree_to_index(repository,
tree,
index,
opts);
diff --git a/libgitg/gitg-stage.vala b/libgitg/gitg-stage.vala
index cc4f63c..95f8123 100644
--- a/libgitg/gitg-stage.vala
+++ b/libgitg/gitg-stage.vala
@@ -1009,7 +1009,12 @@ public class Stage : Object
opts.new_prefix = defopts.new_prefix;
}
- var tree = yield get_head_tree();
+ Ggit.Tree? tree = null;
+
+ if (!d_repository.is_empty())
+ {
+ tree = yield get_head_tree();
+ }
return new Ggit.Diff.tree_to_index(d_repository,
tree,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]