@matheusbsbs / matheus-bagliano / commits / 3ba7e6e29a
Fork 0

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 <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:15 UTC 3ba7e6e29afd67e69ff5963d8ed76728824959a0
3 files changed +12 -5
builtin/config.c
+2 -3
@@ -330,11 +330,10 @@ static int get_colorbool(int print)
330 return get_colorbool_found ? 0 : 1;
331 }
332
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)
334 {
335 - int nongit;
335 + int nongit = !startup_info->have_repository;
336 char *value;
337 - const char *prefix = setup_git_directory_gently(&nongit);
337
338 config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
339
git.c
+2 -2
@@ -319,7 +319,7 @@ static void handle_internal_command(int argc, const char **argv)
319 { "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
320 { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
321 { "commit-tree", cmd_commit_tree, RUN_SETUP },
322 - { "config", cmd_config },
322 + { "config", cmd_config, RUN_SETUP_GENTLY },
323 { "count-objects", cmd_count_objects, RUN_SETUP },
324 { "describe", cmd_describe, RUN_SETUP },
325 { "diff", cmd_diff },
@@ -376,7 +376,7 @@ static void handle_internal_command(int argc, const char **argv)
376 { "reflog", cmd_reflog, RUN_SETUP },
377 { "remote", cmd_remote, RUN_SETUP },
378 { "replace", cmd_replace, RUN_SETUP },
379 - { "repo-config", cmd_config },
379 + { "repo-config", cmd_config, RUN_SETUP_GENTLY },
380 { "rerere", cmd_rerere, RUN_SETUP },
381 { "reset", cmd_reset, RUN_SETUP },
382 { "rev-list", cmd_rev_list, RUN_SETUP },
t/t7006-pager.sh
+8
@@ -134,6 +134,14 @@ test_expect_success TTY 'configuration can disable pager' '
134 ! test -e paginated.out
135 '
136
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 +
145 test_expect_success 'configuration can enable pager (from subdir)' '
146 rm -f paginated.out &&
147 mkdir -p subdir &&