diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-09-25 09:24:10 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-25 09:24:10 +0300 |
commit | 3430fff768b526a8e5877cfe56760d4865350b5e (patch) | |
tree | 762013bf1a7b9c5352d8af87e7a5a74debf82117 | |
parent | 9709ffac8004c3dc62dc946af469ec6d69bfeffb (diff) | |
parent | 417abfde3534ad51a1a47e00ed799e40e3f7b4ae (diff) |
Merge branch 'ow/rev-parse-is-shallow-repo'
"git rev-parse" learned "--is-shallow-repository", that is to be
used in a way similar to existing "--is-bare-repository" and
friends.
* ow/rev-parse-is-shallow-repo:
rev-parse: rev-parse: add --is-shallow-repository
-rw-r--r-- | Documentation/git-rev-parse.txt | 3 | ||||
-rw-r--r-- | builtin/rev-parse.c | 5 | ||||
-rwxr-xr-x | t/t1500-rev-parse.sh | 15 |
3 files changed, 23 insertions, 0 deletions
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index b1293f24bb..0917b8207b 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -235,6 +235,9 @@ print a message to stderr and exit with nonzero status. --is-bare-repository:: When the repository is bare print "true", otherwise "false". +--is-shallow-repository:: + When the repository is shallow print "true", otherwise "false". + --resolve-git-dir <path>:: Check if <path> is a valid repository or a gitfile that points at a valid repository, and print the location of the diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 9f24004c0a..b9c13d3d9d 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")); diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 03d3c7f6d6..5c715fe2cf 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -116,6 +116,21 @@ test_expect_success 'git-path inside sub-dir' ' test_cmp expect actual ' +test_expect_success 'rev-parse --is-shallow-repository in shallow repo' ' + test_commit test_commit && + echo true >expect && + git clone --depth 1 --no-local . shallow && + test_when_finished "rm -rf shallow" && + git -C shallow rev-parse --is-shallow-repository >actual && + test_cmp expect actual +' + +test_expect_success 'rev-parse --is-shallow-repository in non-shallow repo' ' + echo false >expect && + git rev-parse --is-shallow-repository >actual && + test_cmp expect actual +' + test_expect_success 'showing the superproject correctly' ' git rev-parse --show-superproject-working-tree >out && test_must_be_empty out && |