shortlog has USE_PAGER set. setup_pager() may read config even setup_git_dir* is not run yet. This tries to find a repository before the config is read. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin/shortlog.c | 4 +--- git.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 06320f5..bdf3402 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -249,7 +249,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) { static struct shortlog log; static struct rev_info rev; - int nongit; static const struct option options[] = { OPT_BOOLEAN('n', "numbered", &log.sort_by_number, @@ -265,7 +264,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) struct parse_opt_ctx_t ctx; - prefix = setup_git_directory_gently(&nongit); git_config(git_default_config, NULL); shortlog_init(&log); init_revisions(&rev, prefix); @@ -292,7 +290,7 @@ parse_done: log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT; /* assume HEAD if from a tty */ - if (!nongit && !rev.pending.nr && isatty(0)) + if (startup_info->have_repository && !rev.pending.nr && isatty(0)) add_head_to_pending(&rev); if (rev.pending.nr == 0) { if (isatty(0)) diff --git a/git.c b/git.c index 2069ef3..29489e6 100644 --- a/git.c +++ b/git.c @@ -374,7 +374,7 @@ static void handle_internal_command(int argc, const char **argv) { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE }, { "rm", cmd_rm, RUN_SETUP }, { "send-pack", cmd_send_pack, RUN_SETUP }, - { "shortlog", cmd_shortlog, USE_PAGER }, + { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, -- 1.7.0.rc1.541.g2da82.dirty -- 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