summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorØystein Walle <oystwa@gmail.com>2017-09-18 17:04:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-19 03:16:28 (GMT)
commit417abfde3534ad51a1a47e00ed799e40e3f7b4ae (patch)
treeeb25ed542b7e66906863197924077c567f5aad2c /builtin/rev-parse.c
parent94c9fd268d4287f6fbfef84793288479905a7e48 (diff)
downloadgit-417abfde3534ad51a1a47e00ed799e40e3f7b4ae.zip
git-417abfde3534ad51a1a47e00ed799e40e3f7b4ae.tar.gz
git-417abfde3534ad51a1a47e00ed799e40e3f7b4ae.tar.bz2
rev-parse: rev-parse: add --is-shallow-repository
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 c78b7b3..44e9a48 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"));