git wrapper: add --git-dir=<path> and --bare options
[gitweb.git] / builtin-help.c
index 10a59cc403d68166c614f2cf023d62413c5c1fcb..bc1b4da3bc0186487fac40173203cac91c1e3710 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Builtin help-related commands (help, usage, version)
  */
+#include <sys/ioctl.h>
 #include "cache.h"
 #include "builtin.h"
 #include "exec_cmd.h"
@@ -11,7 +12,7 @@
 static const char git_usage[] =
        "Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
 
-/* most gui terms set COLUMNS (although some don't export it) */
+/* most GUI terminals set COLUMNS (although some don't export it) */
 static int term_columns(void)
 {
        char *col_string = getenv("COLUMNS");
@@ -228,7 +229,7 @@ int cmd_version(int argc, const char **argv, char **envp)
 
 int cmd_help(int argc, const char **argv, char **envp)
 {
-       const char *help_cmd = argv[1];
+       const char *help_cmd = argc > 1 ? argv[1] : NULL;
        if (!help_cmd)
                cmd_usage(0, git_exec_path(), NULL);
        else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a"))