Skip to content

Commit

Permalink
config: run setup_git_directory_gently() sooner
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 16, 2010
1 parent 2cb6009 commit 3ba7e6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,10 @@ static int get_colorbool(int print)
return get_colorbool_found ? 0 : 1;
}

int cmd_config(int argc, const char **argv, const char *unused_prefix)
int cmd_config(int argc, const char **argv, const char *prefix)
{
int nongit;
int nongit = !startup_info->have_repository;
char *value;
const char *prefix = setup_git_directory_gently(&nongit);

config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);

Expand Down
4 changes: 2 additions & 2 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
{ "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
{ "config", cmd_config },
{ "config", cmd_config, RUN_SETUP_GENTLY },
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff },
Expand Down Expand Up @@ -376,7 +376,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "reflog", cmd_reflog, RUN_SETUP },
{ "remote", cmd_remote, RUN_SETUP },
{ "replace", cmd_replace, RUN_SETUP },
{ "repo-config", cmd_config },
{ "repo-config", cmd_config, RUN_SETUP_GENTLY },
{ "rerere", cmd_rerere, RUN_SETUP },
{ "reset", cmd_reset, RUN_SETUP },
{ "rev-list", cmd_rev_list, RUN_SETUP },
Expand Down
8 changes: 8 additions & 0 deletions t/t7006-pager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ test_expect_success TTY 'configuration can disable pager' '
! test -e paginated.out
'

test_expect_success 'git config uses a pager if configured to' '
rm -f paginated.out &&
git config pager.config true &&
test_when_finished "git config --unset pager.config" &&
test_terminal git config --list &&
test -e paginated.out
'

test_expect_success 'configuration can enable pager (from subdir)' '
rm -f paginated.out &&
mkdir -p subdir &&
Expand Down

0 comments on commit 3ba7e6e

Please sign in to comment.