[gitg/unstage-selection-new-files] Allow to unstage selection on new files




commit b02cfb9cb2155ac3703af65528fc93c99a99c8a4
Author: Alberto Fanjul <albertofanjul gmail com>
Date:   Fri Aug 5 17:05:47 2022 +0200

    Allow to unstage selection on new files

 libgitg/gitg-stage.vala | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libgitg/gitg-stage.vala b/libgitg/gitg-stage.vala
index 0eb2f071..14de4ae6 100644
--- a/libgitg/gitg-stage.vala
+++ b/libgitg/gitg-stage.vala
@@ -957,14 +957,20 @@ public class Stage : Object
 
                        if (entry == null)
                        {
+                                print("index do not contain "+file.get_path()+"\n");
                                throw new StageError.INDEX_ENTRY_NOT_FOUND(patch.filename);
                        }
 
-                       var head_entry = tree.get_by_path(patch.filename);
-                       var head_blob = d_repository.lookup<Ggit.Blob>(head_entry.get_id());
-                       var index_blob = d_repository.lookup<Ggit.Blob>(entry.get_id());
 
-                       unowned uchar[] head_content = head_blob.get_raw_content();
+                       uchar[] head_content = new uchar[0];
+                        try {
+                           var head_entry = tree.get_by_path(patch.filename);
+                           var head_blob = d_repository.lookup<Ggit.Blob>(head_entry.get_id());
+
+                           head_content = head_blob.get_raw_content();
+                        } catch (Error e) {}
+
+                       var index_blob = d_repository.lookup<Ggit.Blob>(entry.get_id());
                        unowned uchar[] index_content = index_blob.get_raw_content();
 
                        var head_stream = new MemoryInputStream.from_bytes(new Bytes(head_content));


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