Skip to content

Commit c409824

Browse files
Martin Ågrengitster
authored andcommitted
git.c: let builtins opt for handling pager.foo themselves
Before launching a builtin git foo and unless mechanisms with precedence are in use, we check for and handle the `pager.foo` config. This is done without considering exactly how git foo is being used, and indeed, git.c cannot (and should not) know what the arguments to git foo are supposed to achieve. In practice this means that, e.g., `git -c pager.tag tag -a new-tag` results in errors such as "Vim: Warning: Output is not to a terminal" and a garbled terminal. Someone who makes use of both `git tag -a` and `git tag -l` will probably not set `pager.tag`, so that `git tag -a` will actually work, at the cost of not paging output of `git tag -l`. To allow individual builtins to make more informed decisions about when to respect `pager.foo`, introduce a flag DELAY_PAGER_CONFIG. If the flag is set, do not check `pager.foo`. Do not check for DELAY_PAGER_CONFIG in `execv_dashed_external()`. That call site is arguably wrong, although in a way that is not yet visible, and will be changed in a slightly different direction in a later patch. Don't add any users of DELAY_PAGER_CONFIG just yet, one will follow in a later patch. Suggested-by: Jeff King <[email protected]> Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec14d4e commit c409824

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

builtin.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
*
5656
* The built-in supports `--super-prefix`.
5757
*
58+
* `DELAY_PAGER_CONFIG`:
59+
*
60+
* If RUN_SETUP or RUN_SETUP_GENTLY is set, git.c normally handles
61+
* the `pager.<cmd>`-configuration. If this flag is used, git.c
62+
* will skip that step, instead allowing the built-in to make a
63+
* more informed decision, e.g., by ignoring `pager.<cmd>` for
64+
* certain subcommands.
65+
*
5866
* . Add `builtin/foo.o` to `BUILTIN_OBJS` in `Makefile`.
5967
*
6068
* Additionally, if `foo` is a new command, there are 4 more things to do:

git.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static int handle_alias(int *argcp, const char ***argv)
283283
*/
284284
#define NEED_WORK_TREE (1<<3)
285285
#define SUPPORT_SUPER_PREFIX (1<<4)
286+
#define DELAY_PAGER_CONFIG (1<<5)
286287

287288
struct cmd_struct {
288289
const char *cmd;
@@ -306,7 +307,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
306307
prefix = setup_git_directory_gently(&nongit_ok);
307308
}
308309

309-
if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))
310+
if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&
311+
!(p->option & DELAY_PAGER_CONFIG))
310312
use_pager = check_pager_config(p->cmd);
311313
if (use_pager == -1 && p->option & USE_PAGER)
312314
use_pager = 1;

0 commit comments

Comments
 (0)