Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:17 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:17 +0300
commit8d2c37320bd01bbce4b88365c160bc4a542bee48 (patch)
treed805155422fb863b694eaaeb71967d9667f9e81d /git.c
parent3f9d5059c66f45ac75dd701b0798d3891150c1e7 (diff)
parentadd4c864b60766174ad4f74ba7be17e66d61ef16 (diff)
Merge branch 'ld/sparse-diff-blame'
Teach diff and blame to work well with sparse index. * ld/sparse-diff-blame: blame: enable and test the sparse index diff: enable and test the sparse index diff: replace --staged with --cached in t1092 tests repo-settings: prepare_repo_settings only in git repos test-read-cache: set up repo after git directory commit-graph: return if there is no git directory git: ensure correct git directory setup with -h
Diffstat (limited to 'git.c')
-rw-r--r--git.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/git.c b/git.c
index 5ff21be21f..7edafd8ecf 100644
--- a/git.c
+++ b/git.c
@@ -421,27 +421,30 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
int status, help;
struct stat st;
const char *prefix;
+ int run_setup = (p->option & (RUN_SETUP | RUN_SETUP_GENTLY));
- prefix = NULL;
help = argc == 2 && !strcmp(argv[1], "-h");
- if (!help) {
- if (p->option & RUN_SETUP)
- prefix = setup_git_directory();
- else if (p->option & RUN_SETUP_GENTLY) {
- int nongit_ok;
- prefix = setup_git_directory_gently(&nongit_ok);
- }
- precompose_argv_prefix(argc, argv, NULL);
- if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&
- !(p->option & DELAY_PAGER_CONFIG))
- use_pager = check_pager_config(p->cmd);
- if (use_pager == -1 && p->option & USE_PAGER)
- use_pager = 1;
-
- if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) &&
- startup_info->have_repository) /* get_git_dir() may set up repo, avoid that */
- trace_repo_setup(prefix);
+ if (help && (run_setup & RUN_SETUP))
+ /* demote to GENTLY to allow 'git cmd -h' outside repo */
+ run_setup = RUN_SETUP_GENTLY;
+
+ if (run_setup & RUN_SETUP) {
+ prefix = setup_git_directory();
+ } else if (run_setup & RUN_SETUP_GENTLY) {
+ int nongit_ok;
+ prefix = setup_git_directory_gently(&nongit_ok);
+ } else {
+ prefix = NULL;
}
+ precompose_argv_prefix(argc, argv, NULL);
+ if (use_pager == -1 && run_setup &&
+ !(p->option & DELAY_PAGER_CONFIG))
+ use_pager = check_pager_config(p->cmd);
+ if (use_pager == -1 && p->option & USE_PAGER)
+ use_pager = 1;
+ if (run_setup && startup_info->have_repository)
+ /* get_git_dir() may set up repo, avoid that */
+ trace_repo_setup(prefix);
commit_pager_choice();
if (!help && get_super_prefix()) {