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>
This commit is contained in:
parent
94c9fd268d
commit
417abfde35
@ -235,6 +235,9 @@ print a message to stderr and exit with nonzero status.
|
|||||||
--is-bare-repository::
|
--is-bare-repository::
|
||||||
When the repository is bare print "true", otherwise "false".
|
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>::
|
--resolve-git-dir <path>::
|
||||||
Check if <path> is a valid repository or a gitfile that
|
Check if <path> is a valid repository or a gitfile that
|
||||||
points at a valid repository, and print the location of the
|
points at a valid repository, and print the location of the
|
||||||
|
@ -868,6 +868,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
: "false");
|
: "false");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--is-shallow-repository")) {
|
||||||
|
printf("%s\n", is_repository_shallow() ? "true"
|
||||||
|
: "false");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--shared-index-path")) {
|
if (!strcmp(arg, "--shared-index-path")) {
|
||||||
if (read_cache() < 0)
|
if (read_cache() < 0)
|
||||||
die(_("Could not read the index"));
|
die(_("Could not read the index"));
|
||||||
|
@ -116,6 +116,21 @@ test_expect_success 'git-path inside sub-dir' '
|
|||||||
test_cmp expect actual
|
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' '
|
test_expect_success 'showing the superproject correctly' '
|
||||||
git rev-parse --show-superproject-working-tree >out &&
|
git rev-parse --show-superproject-working-tree >out &&
|
||||||
test_must_be_empty out &&
|
test_must_be_empty out &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user