From 417abfde3534ad51a1a47e00ed799e40e3f7b4ae Mon Sep 17 00:00:00 2001 From: Øystein Walle Date: Mon, 18 Sep 2017 19:04:29 +0200 Subject: rev-parse: rev-parse: add --is-shallow-repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running `git fetch --unshallow` on a repo that is not in fact shallow produces a fatal error message. Add a helper to rev-parse that scripters can use to determine whether a repo is shallow or not. Signed-off-by: Øystein Walle Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/rev-parse.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin/rev-parse.c') diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index c78b7b33d6..44e9a48e02 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -868,6 +868,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) : "false"); continue; } + if (!strcmp(arg, "--is-shallow-repository")) { + printf("%s\n", is_repository_shallow() ? "true" + : "false"); + continue; + } if (!strcmp(arg, "--shared-index-path")) { if (read_cache() < 0) die(_("Could not read the index")); -- cgit 1.2.3-korg