summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-09-08 13:30:32 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-08 13:30:32 -0700
commitec8d24f05df6966d229e2078da78ea46aea7b41c (patch)
tree30dfc0d377ac9db670439ff5c621dbb1357b0dde /t
parentMerge branch 'mt/quiet-with-delayed-checkout' (diff)
parentbranch: allow deleting dangling branches with --force (diff)
downloadtgif-ec8d24f05df6966d229e2078da78ea46aea7b41c.tar.xz
Merge branch 'rs/branch-allow-deleting-dangling'
"git branch -D <branch>" used to refuse to remove a broken branch ref that points at a missing commit, which has been corrected. * rs/branch-allow-deleting-dangling: branch: allow deleting dangling branches with --force
Diffstat (limited to 't')
-rwxr-xr-xt/t3200-branch.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index cc4b10236e..e575ffb4ff 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1272,6 +1272,19 @@ test_expect_success 'attempt to delete a branch merged to its base' '
test_must_fail git branch -d my10
'
+test_expect_success 'branch --delete --force removes dangling branch' '
+ git checkout main &&
+ test_commit unstable &&
+ hash=$(git rev-parse HEAD) &&
+ objpath=$(echo $hash | sed -e "s|^..|.git/objects/&/|") &&
+ git branch --no-track dangling &&
+ mv $objpath $objpath.x &&
+ test_when_finished "mv $objpath.x $objpath" &&
+ git branch --delete --force dangling &&
+ git for-each-ref refs/heads/dangling >actual &&
+ test_must_be_empty actual
+'
+
test_expect_success 'use --edit-description' '
write_script editor <<-\EOF &&
echo "New contents" >"$1"