summaryrefslogtreecommitdiff
path: root/t/t6120-describe.sh
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-03-21 22:57:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-22 17:13:41 (GMT)
commitb0176ce6b5d954a747dc4d0c5a8593ed576714c4 (patch)
tree2ff1ee516b34b29613cfe8ac9af99bf377a212f2 /t/t6120-describe.sh
parentc0f9c705890ac30871c70219c4b08d740fb40e2e (diff)
downloadgit-b0176ce6b5d954a747dc4d0c5a8593ed576714c4.zip
git-b0176ce6b5d954a747dc4d0c5a8593ed576714c4.tar.gz
git-b0176ce6b5d954a747dc4d0c5a8593ed576714c4.tar.bz2
builtin/describe: introduce --broken flag
git-describe tells you the version number you're at, or errors out, e.g. when you run it outside of a repository, which may happen when downloading a tar ball instead of using git to obtain the source code. To keep this property of only erroring out, when not in a repository, severe (submodule) errors must be downgraded to reporting them gently instead of having git-describe error out completely. To achieve that a flag '--broken' is introduced, which is in the same vein as '--dirty' but uses an actual child process to check for dirtiness. When that child dies unexpectedly, we'll append '-broken' instead of '-dirty'. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6120-describe.sh')
-rwxr-xr-xt/t6120-describe.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 167491f..16952e4 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -233,4 +233,24 @@ test_expect_success 'describe --contains and --no-match' '
test_cmp expect actual
'
+test_expect_success 'setup and absorb a submodule' '
+ test_create_repo sub1 &&
+ test_commit -C sub1 initial &&
+ git submodule add ./sub1 &&
+ git submodule absorbgitdirs &&
+ git commit -a -m "add submodule" &&
+ git describe --dirty >expect &&
+ git describe --broken >out &&
+ test_cmp expect out
+'
+
+test_expect_success 'describe chokes on severly broken submodules' '
+ mv .git/modules/sub1/ .git/modules/sub_moved &&
+ test_must_fail git describe --dirty
+'
+test_expect_success 'describe ignoring a borken submodule' '
+ git describe --broken >out &&
+ grep broken out
+'
+
test_done