|
6 | 6 | #define DEFAULT_PAGER "less"
|
7 | 7 | #endif
|
8 | 8 |
|
9 |
| -struct pager_config { |
10 |
| - const char *cmd; |
11 |
| - int want; |
12 |
| - char *value; |
13 |
| -}; |
14 |
| - |
15 | 9 | /*
|
16 | 10 | * This is split up from the rest of git so that we can do
|
17 | 11 | * something different on Windows.
|
@@ -155,30 +149,22 @@ int decimal_width(int number)
|
155 | 149 | return width;
|
156 | 150 | }
|
157 | 151 |
|
158 |
| -static int pager_command_config(const char *var, const char *value, void *data) |
| 152 | +/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ |
| 153 | +int check_pager_config(const char *cmd) |
159 | 154 | {
|
160 |
| - struct pager_config *c = data; |
161 |
| - if (starts_with(var, "pager.") && !strcmp(var + 6, c->cmd)) { |
162 |
| - int b = git_config_maybe_bool(var, value); |
| 155 | + int want = -1; |
| 156 | + struct strbuf key = STRBUF_INIT; |
| 157 | + const char *value = NULL; |
| 158 | + strbuf_addf(&key, "pager.%s", cmd); |
| 159 | + if (!git_config_get_value(key.buf, &value)) { |
| 160 | + int b = git_config_maybe_bool(key.buf, value); |
163 | 161 | if (b >= 0)
|
164 |
| - c->want = b; |
| 162 | + want = b; |
165 | 163 | else {
|
166 |
| - c->want = 1; |
167 |
| - c->value = xstrdup(value); |
| 164 | + want = 1; |
| 165 | + pager_program = xstrdup(value); |
168 | 166 | }
|
169 | 167 | }
|
170 |
| - return 0; |
171 |
| -} |
172 |
| - |
173 |
| -/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ |
174 |
| -int check_pager_config(const char *cmd) |
175 |
| -{ |
176 |
| - struct pager_config c; |
177 |
| - c.cmd = cmd; |
178 |
| - c.want = -1; |
179 |
| - c.value = NULL; |
180 |
| - git_config(pager_command_config, &c); |
181 |
| - if (c.value) |
182 |
| - pager_program = c.value; |
183 |
| - return c.want; |
| 168 | + strbuf_release(&key); |
| 169 | + return want; |
184 | 170 | }
|
0 commit comments