index-pack: complain when --stdin is used outside of a repo
[gitweb.git] / builtin / index-pack.c
index 0a27bab11b6b5a1b162c4dfef34c645c7d5f14ad..d450a6ada2a247fc316caada8820241fdf975e0f 100644 (file)
@@ -1730,6 +1730,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                usage(index_pack_usage);
        if (fix_thin_pack && !from_stdin)
                die(_("--fix-thin cannot be used without --stdin"));
+       if (from_stdin && !startup_info->have_repository)
+               die(_("--stdin requires a git repository"));
        if (!index_name && pack_name)
                index_name = derive_filename(pack_name, ".idx", &index_name_buf);
        if (keep_msg && !keep_name && pack_name)