summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorØystein Walle <oystwa@gmail.com>2017-09-18 19:04:29 +0200
committerJunio C Hamano <gitster@pobox.com>2017-09-19 12:16:28 +0900
commit417abfde3534ad51a1a47e00ed799e40e3f7b4ae (patch)
treeeb25ed542b7e66906863197924077c567f5aad2c /builtin/rev-parse.c
parent94c9fd268d4287f6fbfef84793288479905a7e48 (diff)
downloadgit-417abfde3534ad51a1a47e00ed799e40e3f7b4ae.tar.gz
rev-parse: rev-parse: add --is-shallow-repositoryow/rev-parse-is-shallow-repo
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 <oystwa@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c5
1 files changed, 5 insertions, 0 deletions
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"));