aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-02-18 13:53:30 -0800
committerJunio C Hamano <gitster@pobox.com>2022-02-18 13:53:30 -0800
commitc5973cb98ff4fe0779e90e04de7c099cc2256a3a (patch)
treed09aedb1405c3b20e31b81c982edf697e4036fbc /builtin/checkout.c
parentMerge branch 'tb/midx-no-bitmap-for-no-objects' (diff)
parentt0012: verify that built-ins handle `-h` even without gitdir (diff)
downloadgit-c5973cb98ff4fe0779e90e04de7c099cc2256a3a.tar.gz
git-c5973cb98ff4fe0779e90e04de7c099cc2256a3a.zip
Merge branch 'js/short-help-outside-repo-fix'
"git cmd -h" outside a repository should error out cleanly for many commands, but instead it hit a BUG(), which has been corrected. * js/short-help-outside-repo-fix: t0012: verify that built-ins handle `-h` even without gitdir checkout/fetch/pull/pack-objects: allow `-h` outside a repository
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2b33960e21..d9b31bbb6d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1608,9 +1608,10 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
opts->show_progress = -1;
git_config(git_checkout_config, opts);
-
- prepare_repo_settings(the_repository);
- the_repository->settings.command_requires_full_index = 0;
+ if (the_repository->gitdir) {
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+ }
opts->track = BRANCH_TRACK_UNSPECIFIED;