shortlog: run setup_git_directory_gently() sooner
shortlog already runs a repository search unconditionally; running such a search earlier is not very risky. Without this change, the “[pager] shortlog” configuration is not respected at all: “git shortlog” unconditionally paginates. The tests are a bit slow. Running the full battery like this for all built-in commands would be counterproductive; the intent is rather to test shortlog as a representative example command using ..._gently(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Aug 5, 2010 at 22:01 UTC
773b69bf7189f5babb26b899b4c35f604cd993c7
3 files changed
+11
-3
builtin/shortlog.c
+1
-2
@@ -249,7 +249,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
249
{
250
static struct shortlog log;
251
static struct rev_info rev;
252
- int nongit;
252
+ int nongit = !startup_info->have_repository;
253
254
static const struct option options[] = {
255
OPT_BOOLEAN('n', "numbered", &log.sort_by_number,
@@ -265,7 +265,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
265
266
struct parse_opt_ctx_t ctx;
267
268
- prefix = setup_git_directory_gently(&nongit);
268
git_config(git_default_config, NULL);
269
shortlog_init(&log);
270
init_revisions(&rev, prefix);
git.c
+1
-1
@@ -384,7 +384,7 @@ static void handle_internal_command(int argc, const char **argv)
384
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
385
{ "rm", cmd_rm, RUN_SETUP },
386
{ "send-pack", cmd_send_pack, RUN_SETUP },
387
- { "shortlog", cmd_shortlog, USE_PAGER },
387
+ { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
388
{ "show-branch", cmd_show_branch, RUN_SETUP },
389
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
390
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
t/t7006-pager.sh
+9
@@ -369,4 +369,13 @@ test_GIT_PAGER_overrides expect_success test_must_fail 'git -p'
369
370
test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense'
371
372
+test_pager_choices 'git shortlog'
373
+test_expect_success 'setup: configure shortlog not to paginate' '
374
+ git config pager.shortlog false
375
+'
376
+test_doesnt_paginate expect_success 'git shortlog'
377
+test_no_local_config_subdir expect_success 'git shortlog'
378
+test_default_pager expect_success 'git -p shortlog'
379
+test_core_pager_subdir expect_success 'git -p shortlog'
380
+
381
test_done