[gitg] Handle bare repository cloning



commit 7ef068e6696db9e95a2ca52ed20e726028b0e5ea
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Mar 26 13:03:54 2013 +0100

    Handle bare repository cloning

 gitg/gitg-window.vala                  |    4 +++-
 gitg/resources/ui/gitg-clone-dialog.ui |   16 ++++++++++++++++
 libgitg-gtk/gitg-gtk-dash-view.vala    |   20 +++++++++++++++-----
 3 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index a907634..8d4846c 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -194,11 +194,13 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                                                  "dialog-clone",
                                                  "entry-url",
                                                  "filechooserbutton-location",
+                                                 "checkbutton-bare-repository",
                                                  "ok-button");
 
                var dlg = ret["dialog-clone"] as Gtk.Dialog;
                var entry_url = ret["entry-url"] as Gtk.Entry;
                var chooser = ret["filechooserbutton-location"] as Gtk.FileChooserButton;
+               var bare = ret["checkbutton-bare-repository"] as Gtk.CheckButton;
                var ok_button = ret["ok-button"] as Gtk.Button;
 
                dlg.modal = true;
@@ -211,7 +213,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                dlg.response.connect((d, id) => {
                        if (id == Gtk.ResponseType.OK)
                        {
-                               d_dash_view.clone_repository(entry_url.get_text(), chooser.get_file());
+                               d_dash_view.clone_repository(entry_url.get_text(), chooser.get_file(), 
bare.get_active());
                        }
 
                        d.destroy();
diff --git a/gitg/resources/ui/gitg-clone-dialog.ui b/gitg/resources/ui/gitg-clone-dialog.ui
index 32bbe29..39d6f95 100644
--- a/gitg/resources/ui/gitg-clone-dialog.ui
+++ b/gitg/resources/ui/gitg-clone-dialog.ui
@@ -115,6 +115,22 @@
                 <property name="height">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkCheckButton" id="checkbutton-bare-repository">
+                <property name="label" translatable="yes">Bare repository</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/libgitg-gtk/gitg-gtk-dash-view.vala b/libgitg-gtk/gitg-gtk-dash-view.vala
index d4407d1..d361b6d 100644
--- a/libgitg-gtk/gitg-gtk-dash-view.vala
+++ b/libgitg-gtk/gitg-gtk-dash-view.vala
@@ -254,7 +254,7 @@ namespace GitgGtk
                        }
                }
 
-               private async Gitg.Repository? clone(string url, File location)
+               private async Gitg.Repository? clone(string url, File location, bool is_bare)
                {
                        SourceFunc callback = clone.callback;
                        Gitg.Repository? repository = null;
@@ -262,7 +262,10 @@ namespace GitgGtk
                        ThreadFunc<void*> run = () => {
                                try
                                {
-                                       repository = Ggit.Repository.clone(url, location, null) as 
Gitg.Repository;
+                                       var options = new Ggit.CloneOptions();
+                                       options.set_is_bare(is_bare);
+
+                                       repository = Ggit.Repository.clone(url, location, options) as 
Gitg.Repository;
                                }
                                catch (Ggit.Error e)
                                {
@@ -287,13 +290,20 @@ namespace GitgGtk
                        return repository;
                }
 
-               public void clone_repository(string url, File location)
+               public void clone_repository(string url, File location, bool is_bare)
                {
                        // create subfolder
                        var subfolder_name = url.substring(url.last_index_of_char('/') + 1);
                        if (subfolder_name.has_suffix(".git"))
                        {
-                               subfolder_name = subfolder_name.slice(0, - ".git".length);
+                               if (!is_bare)
+                               {
+                                       subfolder_name = subfolder_name.slice(0, - ".git".length);
+                               }
+                       }
+                       else
+                       {
+                               subfolder_name += ".git";
                        }
 
                        var subfolder = location.resolve_relative_path(subfolder_name);
@@ -311,7 +321,7 @@ namespace GitgGtk
                        // Clone
                        RepositoryData? data = create_repository_data(subfolder_name, "Cloning...", true);
 
-                       clone.begin(url, subfolder, (obj, res) => {
+                       clone.begin(url, subfolder, is_bare, (obj, res) => {
                                Gitg.Repository? repository = clone.end(res);
                                string branch_name = "";
 


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