Index: glib/goption.c
===================================================================
--- glib/goption.c	(revision 6147)
+++ glib/goption.c	(working copy)
@@ -520,6 +520,23 @@ print_entry (GOptionGroup       *group,
   g_string_free (str, TRUE);  
 }
 
+static gboolean
+group_has_displayed_non_main_entries (GOptionGroup *group)
+{
+  GOptionEntry *entry;
+  gint i;
+
+  for (i = 0; i < group->n_entries; i++)
+    {
+      entry = &group->entries[i];
+
+      if (!(entry->flags & (G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_IN_MAIN)))
+	return TRUE;
+    }
+
+  return FALSE;
+}
+
 /**
  * g_option_context_get_help: 
  * @context: a #GOptionContext
@@ -687,9 +704,10 @@ g_option_context_get_help (GOptionContex
 	{
 	  GOptionGroup *group = list->data;
 	  
-	  g_string_append_printf (string, "  --help-%-*s %s\n", 
-                                  max_length - 5, group->name, 
-		                  TRANSLATE (group, group->help_description));
+	  if (group_has_displayed_non_main_entries (group))
+	    g_string_append_printf (string, "  --help-%-*s %s\n", 
+				    max_length - 5, group->name, 
+				    TRANSLATE (group, group->help_description));
 	  
 	  list = list->next;
 	}
@@ -717,13 +735,17 @@ g_option_context_get_help (GOptionContex
 	{
 	  GOptionGroup *group = list->data;
 
-	  g_string_append (string, group->description);
-          g_string_append (string, "\n");
-	  for (i = 0; i < group->n_entries; i++)
-	    if (!(group->entries[i].flags & G_OPTION_FLAG_IN_MAIN))
-	      print_entry (group, max_length, &group->entries[i], string);
+	  if (group_has_displayed_non_main_entries (group))
+	    {
+	      g_string_append (string, group->description);
+	      g_string_append (string, "\n");
+	      for (i = 0; i < group->n_entries; i++)
+		if (!(group->entries[i].flags & G_OPTION_FLAG_IN_MAIN))
+		  print_entry (group, max_length, &group->entries[i], string);
 	  
-	  g_string_append (string, "\n");
+	      g_string_append (string, "\n");
+	    }
+
 	  list = list->next;
 	}
     }
