Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin-config.c | 12 ++++++------ git.c | 4 ++-- t/t1302-repo-version.sh | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/builtin-config.c b/builtin-config.c index 4bc46b1..944ec9d 100644 --- a/builtin-config.c +++ b/builtin-config.c @@ -159,7 +159,8 @@ static int get_value(const char *key_, const char *regex_) local = config_exclusive_filename; if (!local) { const char *home = getenv("HOME"); - local = repo_config = git_pathdup("config"); + if (startup_info->have_repository) + local = repo_config = git_pathdup("config"); if (git_config_global() && home) global = xstrdup(mkpath("%s/.gitconfig", home)); if (git_config_system()) @@ -197,7 +198,8 @@ static int get_value(const char *key_, const char *regex_) git_config_from_file(show_config, system_wide, NULL); if (do_all && global) git_config_from_file(show_config, global, NULL); - git_config_from_file(show_config, local, NULL); + if (local) + git_config_from_file(show_config, local, NULL); if (!do_all && !seen && global) git_config_from_file(show_config, global, NULL); if (!do_all && !seen && system_wide) @@ -326,11 +328,9 @@ 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; char *value; - const char *prefix = setup_git_directory_gently(&nongit); config_exclusive_filename = getenv(CONFIG_ENVIRONMENT); @@ -409,7 +409,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix) } else if (actions == ACTION_EDIT) { check_argc(argc, 0, 0); - if (!config_exclusive_filename && nongit) + if (!config_exclusive_filename && !startup_info->have_repository) die("not in a git directory"); git_config(git_default_config, NULL); launch_editor(config_exclusive_filename ? diff --git a/git.c b/git.c index 5391292..0022f02 100644 --- a/git.c +++ b/git.c @@ -322,7 +322,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 }, @@ -378,7 +378,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 }, diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index 8d305b4..74bf51f 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -29,7 +29,7 @@ test_expect_success 'gitdir selection on normal repos' ' # Make sure it would stop at test2, not trash test_expect_success 'gitdir selection on unsupported repo' ' (cd test2 && - test "$(git config core.repositoryformatversion)" = 99)' + test "$(git config --file=.git/config core.repositoryformatversion)" = 99)' test_expect_success 'gitdir not required mode' ' (git apply --stat test.patch && -- 1.7.0.195.g637a2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html