[gnome-builder/wip/chergert/headerbar] vcs: add fallback branch names



commit 8f471ad562d0b16db4deead34d0ed60b158710f1
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jun 25 19:45:02 2016 -0700

    vcs: add fallback branch names

 libide/directory/ide-directory-vcs.c |    7 +++++++
 plugins/git/ide-git-vcs.c            |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/libide/directory/ide-directory-vcs.c b/libide/directory/ide-directory-vcs.c
index 3ef1219..0c4d487 100644
--- a/libide/directory/ide-directory-vcs.c
+++ b/libide/directory/ide-directory-vcs.c
@@ -193,10 +193,17 @@ ide_directory_vcs_get_priority (IdeVcs *vcs)
   return G_MAXINT;
 }
 
+static gchar *
+ide_directory_vcs_get_branch_name (IdeVcs *vcs)
+{
+  return g_strdup (_("unversioned"));
+}
+
 static void
 vcs_iface_init (IdeVcsInterface *iface)
 {
   iface->get_working_directory = ide_directory_vcs_get_working_directory;
   iface->is_ignored = ide_directory_vcs_is_ignored;
   iface->get_priority = ide_directory_vcs_get_priority;
+  iface->get_branch_name = ide_directory_vcs_get_branch_name;
 }
diff --git a/plugins/git/ide-git-vcs.c b/plugins/git/ide-git-vcs.c
index 1548c0f..f2e64a3 100644
--- a/plugins/git/ide-git-vcs.c
+++ b/plugins/git/ide-git-vcs.c
@@ -362,6 +362,11 @@ ide_git_vcs_get_branch_name (IdeVcs *vcs)
       ret = g_strdup (ggit_ref_get_shorthand (ref));
       g_object_unref (ref);
     }
+  else
+    {
+      /* initial commit, no branch name yet */
+      ret = g_strdup ("master");
+    }
 
   return ret;
 }


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