[WIP PATCH 10/26] shortlog: move up gitdir setup to run_builtin()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



shortlog has USE_PAGER set. setup_pager() may read config even
setup_git_dir* is not run yet. When the config path is required,
setup_git_env() plays hero and set gitdir to ".git". Shortly after,
setup_git_dir* is run inside cmd_shortlog() and may move gitdir
to somewhere else.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 builtin-shortlog.c  |    4 +---
 git.c               |    2 +-
 t/t4201-shortlog.sh |    2 ++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index b3b055f..a62dfb0 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) {
 		read_from_stdin(&log);
diff --git a/git.c b/git.c
index a165b43..c7af80e 100644
--- a/git.c
+++ b/git.c
@@ -386,7 +386,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 },
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index a01e55b..7ae327a 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -8,6 +8,8 @@ test_description='git shortlog
 
 . ./test-lib.sh
 
+export GIT_HARDENED_SETUP=1
+
 echo 1 > a1
 git add a1
 tree=$(git write-tree)
-- 
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]