path: root/builtin/config.c
diff options
authorJeff King <>2018-05-18 22:27:04 (GMT)
committerJunio C Hamano <>2018-05-21 00:47:13 (GMT)
commit17b8a2d6cdfc359b1a7de6dd215dc3c32ab1dbfe (patch)
tree9555b1a5ed7a22b96f06093a536c52c4573c7921 /builtin/config.c
parent468165c1d8a442994a825f3684528361727cd8c0 (diff)
config: die when --blob is used outside a repository
If you run "config --blob" outside of a repository, then we eventually try to resolve the blob name and hit a BUG(). Let's catch this earlier and provide a useful message. Note that we could also catch this much lower in the stack, in git_config_from_blob_ref(). That might cover other callsites, too, but it's unclear whether those ones would actually be bugs or not. So let's leave the low-level functions to assume the caller knows what it's doing (and BUG() if it turns out it doesn't). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/config.c')
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 01169dd..d004397 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -513,6 +513,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (use_local_config && nongit)
die(_("--local 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, "-")) {
given_config_source.file = NULL;