Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
pager.c: replace `git_config()` with `git_config_get_value()`
author
Tanay Abhra
<tanayabh@gmail.com>
Thu, 7 Aug 2014 16:21:23 +0000
(09:21 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 7 Aug 2014 20:33:28 +0000
(13:33 -0700)
Use `git_config_get_value()` instead of `git_config()` to take advantage of
the config-set API which provides a cleaner control flow.
Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pager.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5801d3b
)
diff --git
a/pager.c
b/pager.c
index 8b5cbc56e4fd57a1b9d2cad3e668df4c508a7b17..b7eb7e7957f5e6340e0590fad9a362fd0086e6fa 100644
(file)
--- a/
pager.c
+++ b/
pager.c
@@
-6,12
+6,6
@@
#define DEFAULT_PAGER "less"
#endif
#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.
/*
* This is split up from the rest of git so that we can do
* something different on Windows.
@@
-155,30
+149,22
@@
int decimal_width(int number)
return width;
}
return width;
}
-static int pager_command_config(const char *var, const char *value, void *data)
+/* 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 = data;
- if (starts_with(var, "pager.") && !strcmp(var + 6, c->cmd)) {
- int b = git_config_maybe_bool(var, value);
+ int want = -1;
+ struct strbuf key = STRBUF_INIT;
+ const char *value = NULL;
+ strbuf_addf(&key, "pager.%s", cmd);
+ if (!git_config_get_value(key.buf, &value)) {
+ int b = git_config_maybe_bool(key.buf, value);
if (b >= 0)
if (b >= 0)
-
c->
want = b;
+ want = b;
else {
else {
-
c->
want = 1;
-
c->value
= xstrdup(value);
+ want = 1;
+
pager_program
= 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;
+ strbuf_release(&key);
+ return want;
}
}