Skip to content

Commit 3ba7e6e

Browse files
pcloudsgitster
authored andcommitted
config: run setup_git_directory_gently() sooner
For the pager choice (and the choice to paginate) to reflect the current repository configuration, the repository needs to be located first. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2cb6009 commit 3ba7e6e

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

builtin/config.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,10 @@ static int get_colorbool(int print)
330330
return get_colorbool_found ? 0 : 1;
331331
}
332332

333-
int cmd_config(int argc, const char **argv, const char *unused_prefix)
333+
int cmd_config(int argc, const char **argv, const char *prefix)
334334
{
335-
int nongit;
335+
int nongit = !startup_info->have_repository;
336336
char *value;
337-
const char *prefix = setup_git_directory_gently(&nongit);
338337

339338
config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
340339

git.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static void handle_internal_command(int argc, const char **argv)
319319
{ "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
320320
{ "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
321321
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
322-
{ "config", cmd_config },
322+
{ "config", cmd_config, RUN_SETUP_GENTLY },
323323
{ "count-objects", cmd_count_objects, RUN_SETUP },
324324
{ "describe", cmd_describe, RUN_SETUP },
325325
{ "diff", cmd_diff },
@@ -376,7 +376,7 @@ static void handle_internal_command(int argc, const char **argv)
376376
{ "reflog", cmd_reflog, RUN_SETUP },
377377
{ "remote", cmd_remote, RUN_SETUP },
378378
{ "replace", cmd_replace, RUN_SETUP },
379-
{ "repo-config", cmd_config },
379+
{ "repo-config", cmd_config, RUN_SETUP_GENTLY },
380380
{ "rerere", cmd_rerere, RUN_SETUP },
381381
{ "reset", cmd_reset, RUN_SETUP },
382382
{ "rev-list", cmd_rev_list, RUN_SETUP },

t/t7006-pager.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ test_expect_success TTY 'configuration can disable pager' '
134134
! test -e paginated.out
135135
'
136136

137+
test_expect_success 'git config uses a pager if configured to' '
138+
rm -f paginated.out &&
139+
git config pager.config true &&
140+
test_when_finished "git config --unset pager.config" &&
141+
test_terminal git config --list &&
142+
test -e paginated.out
143+
'
144+
137145
test_expect_success 'configuration can enable pager (from subdir)' '
138146
rm -f paginated.out &&
139147
mkdir -p subdir &&

0 commit comments

Comments
 (0)