Update draft release notes to 1.6.6 before merging topics for -rc1
[gitweb.git] / var.c
diff --git a/var.c b/var.c
index 7362ed87354a4bea98c28f9a8c315b7209c67fa2..d9892f85ce954883427ac4f61d9de9d591c0827c 100644 (file)
--- a/var.c
+++ b/var.c
@@ -8,6 +8,25 @@
 
 static const char var_usage[] = "git var [-l | <variable>]";
 
+static const char *editor(int flag)
+{
+       const char *pgm = git_editor();
+
+       if (!pgm && flag & IDENT_ERROR_ON_NO_NAME)
+               die("Terminal is dumb, but EDITOR unset");
+
+       return pgm;
+}
+
+static const char *pager(int flag)
+{
+       const char *pgm = git_pager();
+
+       if (!pgm)
+               pgm = "cat";
+       return pgm;
+}
+
 struct git_var {
        const char *name;
        const char *(*read)(int);
@@ -15,15 +34,19 @@ struct git_var {
 static struct git_var git_vars[] = {
        { "GIT_COMMITTER_IDENT", git_committer_info },
        { "GIT_AUTHOR_IDENT",   git_author_info },
+       { "GIT_EDITOR", editor },
+       { "GIT_PAGER", pager },
        { "", NULL },
 };
 
 static void list_vars(void)
 {
        struct git_var *ptr;
-       for(ptr = git_vars; ptr->read; ptr++) {
-               printf("%s=%s\n", ptr->name, ptr->read(IDENT_WARN_ON_NO_NAME));
-       }
+       const char *val;
+
+       for (ptr = git_vars; ptr->read; ptr++)
+               if ((val = ptr->read(0)))
+                       printf("%s=%s\n", ptr->name, val);
 }
 
 static const char *read_var(const char *var)
@@ -31,7 +54,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;