rerere: don't segfault on failure to open rr-cache
[gitweb.git] / var.c
diff --git a/var.c b/var.c
index f1eb314e899c518b8dea54b4ff8f3923da7b12cf..125c0d1676abae6de29de14061d1a24fd842712d 100644 (file)
--- a/var.c
+++ b/var.c
@@ -4,6 +4,7 @@
  * Copyright (C) Eric Biederman, 2005
  */
 #include "cache.h"
+#include "exec_cmd.h"
 
 static const char var_usage[] = "git var [-l | <variable>]";
 
@@ -20,9 +21,8 @@ static struct git_var git_vars[] = {
 static void list_vars(void)
 {
        struct git_var *ptr;
-       for(ptr = git_vars; ptr->read; ptr++) {
+       for (ptr = git_vars; ptr->read; ptr++)
                printf("%s=%s\n", ptr->name, ptr->read(IDENT_WARN_ON_NO_NAME));
-       }
 }
 
 static const char *read_var(const char *var)
@@ -30,7 +30,7 @@ static const char *read_var(const char *var)
        struct git_var *ptr;
        const char *val;
        val = NULL;
-       for(ptr = git_vars; ptr->read; ptr++) {
+       for (ptr = git_vars; ptr->read; ptr++) {
                if (strcmp(var, ptr->name) == 0) {
                        val = ptr->read(IDENT_ERROR_ON_NO_NAME);
                        break;
@@ -56,6 +56,8 @@ int main(int argc, char **argv)
                usage(var_usage);
        }
 
+       git_extract_argv0_path(argv[0]);
+
        setup_git_directory_gently(&nongit);
        val = NULL;