push: require force for annotated tags
[gitweb.git] / pager.c
diff --git a/pager.c b/pager.c
index c0b4387d969476232a4e00a7acf9b06dc4ef6edc..c1ecf657fdb32c1fa669f08ba33e358f15c5a07b 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -6,6 +6,12 @@
 #define DEFAULT_PAGER "less"
 #endif
 
+struct pager_config {
+       const char *cmd;
+       int want;
+       char *value;
+};
+
 /*
  * This is split up from the rest of git so that we can do
  * something different on Windows.
@@ -141,3 +147,31 @@ int decimal_width(int number)
                i *= 10;
        return width;
 }
+
+static int pager_command_config(const char *var, const char *value, void *data)
+{
+       struct pager_config *c = data;
+       if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd)) {
+               int b = git_config_maybe_bool(var, value);
+               if (b >= 0)
+                       c->want = b;
+               else {
+                       c->want = 1;
+                       c->value = xstrdup(value);
+               }
+       }
+       return 0;
+}
+
+/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */
+int check_pager_config(const char *cmd)
+{
+       struct pager_config c;
+       c.cmd = cmd;
+       c.want = -1;
+       c.value = NULL;
+       git_config(pager_command_config, &c);
+       if (c.value)
+               pager_program = c.value;
+       return c.want;
+}