summaryrefslogtreecommitdiff
path: root/t/t2020-checkout-detach.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-05-10 17:49:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-05-10 17:49:25 (GMT)
commitdc7a4c386dea4044543ff687dfb99a05e0df26e5 (patch)
tree885f944979956c022f79abec8264f3a7cc317627 /t/t2020-checkout-detach.sh
parent499e7b31509cfbb59dcb2a046f8e2fd1a3e73d6f (diff)
parent5d8863954f077d2c262d5cc4fc669947ff23d6d5 (diff)
downloadgit-dc7a4c386dea4044543ff687dfb99a05e0df26e5.zip
git-dc7a4c386dea4044543ff687dfb99a05e0df26e5.tar.gz
git-dc7a4c386dea4044543ff687dfb99a05e0df26e5.tar.bz2
Merge branch 'js/checkout-detach-count'
When checking out another commit from an already detached state, we used to report all commits that are not reachable from any of the refs as lossage, but some of them might be reachable from the new HEAD, and there is no need to warn about them. By Johannes Sixt * js/checkout-detach-count: checkout (detached): truncate list of orphaned commits at the new HEAD t2020-checkout-detach: check for the number of orphaned commits
Diffstat (limited to 't/t2020-checkout-detach.sh')
-rwxr-xr-xt/t2020-checkout-detach.sh21
1 files changed, 16 insertions, 5 deletions
diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh
index b37ce25..8100537 100755
--- a/t/t2020-checkout-detach.sh
+++ b/t/t2020-checkout-detach.sh
@@ -11,14 +11,13 @@ check_not_detached () {
git symbolic-ref -q HEAD >/dev/null
}
-ORPHAN_WARNING='you are leaving .* commit.*behind'
PREV_HEAD_DESC='Previous HEAD position was'
check_orphan_warning() {
- test_i18ngrep "$ORPHAN_WARNING" "$1" &&
+ test_i18ngrep "you are leaving $2 behind" "$1" &&
test_i18ngrep ! "$PREV_HEAD_DESC" "$1"
}
check_no_orphan_warning() {
- test_i18ngrep ! "$ORPHAN_WARNING" "$1" &&
+ test_i18ngrep ! "you are leaving .* commit.*behind" "$1" &&
test_i18ngrep "$PREV_HEAD_DESC" "$1"
}
@@ -110,12 +109,24 @@ test_expect_success 'checkout warns on orphan commits' '
git checkout --detach two &&
echo content >orphan &&
git add orphan &&
- git commit -a -m orphan &&
+ git commit -a -m orphan1 &&
+ echo new content >orphan &&
+ git commit -a -m orphan2 &&
+ orphan2=$(git rev-parse HEAD) &&
git checkout master 2>stderr
'
test_expect_success 'checkout warns on orphan commits: output' '
- check_orphan_warning stderr
+ check_orphan_warning stderr "2 commits"
+'
+
+test_expect_success 'checkout warns orphaning 1 of 2 commits' '
+ git checkout "$orphan2" &&
+ git checkout HEAD^ 2>stderr
+'
+
+test_expect_success 'checkout warns orphaning 1 of 2 commits: output' '
+ check_orphan_warning stderr "1 commit"
'
test_expect_success 'checkout does not warn leaving ref tip' '