GitRepo.vala
[gitlive] / GitRepo.vala
index e962e5d..a14bb54 100644 (file)
@@ -16,6 +16,8 @@ public class GitRepo : Object
     public string gitdir;
     public string git_working_dir;
     public bool debug = false;
+    
+    public Gee.HashMap<string,bool> ignore_files;
 
     /**
     * index of.. matching gitpath..
@@ -33,7 +35,6 @@ public class GitRepo : Object
     
     }
     
-     
     
     public static   Array<GitRepo> list()
     {
@@ -60,7 +61,8 @@ public class GitRepo : Object
             return list_cache;
             
         }
-         
+        
+        
         FileInfo next_file; 
         
         while (true) {
@@ -124,7 +126,7 @@ public class GitRepo : Object
     public GitRepo(string path) {
         // cal parent?
         this.name =   File.new_for_path(path).get_basename();
-        
+        this.ignore_files = new Gee.HashMap<string,bool>();
         
         this.git_working_dir = path;
         this.gitdir = path + "/.git";
@@ -159,6 +161,24 @@ public class GitRepo : Object
         }
         return ret;
     }
+        
+    public bool is_ignore(string fname) throws Error, SpawnError
+    {
+               if (this.ignore_files.has_key(fname)) {
+                       return this.ignore_files.get(fname);
+               }
+               
+               try {
+                       var ret = this.git( { "check-ignore" , fname } );
+                       this.ignore_files.set(fname, ret == fname);
+                       return ret == fname;
+               } catch (SpawnError e) {
+                       this.ignore_files.set(fname, false);
+                       return false;
+               }
+                
+    } 
+    
     
       /**
      * remove:
@@ -261,9 +281,12 @@ public class GitRepo : Object
     public string push () throws Error, SpawnError
     {
         // should 
-        return this.git({ "push" });
+        return this.git({ "push", "origin", "HEAD" });
         
     }
+    
+    
+    
      /**
      * git:
      * The meaty part.. run spawn.. with git..