diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2020-09-09 10:16:08 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-09 12:47:47 -0700 |
commit | 378fe5fc3d5e415b2d7062e29bc99029dc3418d5 (patch) | |
tree | 5cb7f4d175af6aed63dec9cbde3e45deb2261317 /builtin/config.c | |
parent | Git 2.28 (diff) | |
download | tgif-378fe5fc3d5e415b2d7062e29bc99029dc3418d5.tar.xz |
config: complain about --worktree outside of a git repo
Running `git config --worktree` outside of a git repository hits a BUG()
when trying to enumerate the worktrees. Let's catch this error earlier
and die() with a friendlier message.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/config.c')
-rw-r--r-- | builtin/config.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/builtin/config.c b/builtin/config.c index 5e39f61885..53e411d68a 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -628,11 +628,15 @@ int cmd_config(int argc, const char **argv, const char *prefix) usage_builtin_config(); } - if (use_local_config && nongit) - die(_("--local can only be used inside a git repository")); + if (nongit) { + if (use_local_config) + die(_("--local can only be used inside a git repository")); + if (given_config_source.blob) + die(_("--blob can only be used inside a git repository")); + if (use_worktree_config) + die(_("--worktree can only be used inside a git repository")); - if (given_config_source.blob && nongit) - die(_("--blob can only be used inside a git repository")); + } if (given_config_source.file && !strcmp(given_config_source.file, "-")) { |