{"thread":{"id":"9548","subject":"[PATCH] gitk: Fix warning when removing a branch (take 2)","startedAt":"2007-08-16T01:08:35Z","lastAt":"2007-08-16T11:46:46Z","messageCount":3,"participants":["Mark Levedahl","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50845","messageId":"11872265153600-git-send-email-mdl123@verizon.net","threadId":"9548","inReplyTo":null,"subject":"[PATCH] gitk: Fix warning when removing a branch (take 2)","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-16T01:08:35Z","receivedAt":"2007-08-16T01:08:35Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Issue a warning about branch deletion unless gitk knows by name at least\ntwo branch heads pointing to the referenced commit.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n\nPaul - your commit b1054ac98 did not solve this for me. Playing around, I've\nseveral times received errors like this when trying to delete a branch:\n\ncan't read \"idheads(f7b9ebd595c954cd0803e6b6f1f0f96a966e04c9 a890c4fca84a2a5c7835fe6432ede3e7c4e5426b)\": no such element in array\ncan't read \"idheads(f7b9ebd595c954cd0803e6b6f1f0f96a966e04c9 a890c4fca84a2a5c7835fe6432ede3e7c4e5426b)\": no such element in array\n    while executing\n\"if {$idheads($dheads) eq $head} {\n\t# the stuff on this branch isn't on any other branch\n\tif {![confirm_popup \"The commits on branch $head aren't on an...\"\n    (procedure \"rmbranch\" line 13)\n    invoked from within\n\"rmbranch\"\n    (menu invoke)\n\nHowever, I took a different approach: if the commit in question has at\nleast two branch heads as descendents, deleting one will not leave it\ndangling. I am not sure your code attempted to do this anyway.\n\n\n gitk |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex aa8baf8..d99a974 100755\n--- a/gitk\n+++ b/gitk\n@@ -6208,10 +6208,16 @@ proc rmbranch {} {\n \treturn\n     }\n     set dheads [descheads $id]\n-    if {$idheads($dheads) eq $head} {\n-\t# the stuff on this branch isn't on any other branch\n-\tif {![confirm_popup \"The commits on branch $head aren't on any other\\\n-\t\t\tbranch.\\nReally delete branch $head?\"]} return\n+    set nheads [llength $dheads]\n+    if {$nheads < 2} {\n+\tcatch {\n+\t    set nheads [llength $idheads($dheads)]\n+\t}\n+\tif {$nheads < 2} {\n+\t    # the stuff on this branch isn't on any other branch that we know about\n+\t    if {![confirm_popup \"The commits on branch $head aren't on any other\\\n+\t\t\t    branch.\\nReally delete branch $head?\"]} return\n+\t}\n     }\n     nowbusy rmbranch\n     update\n--\n1.5.3.rc4.85.g3ba6\n"},{"id":"50846","messageId":"18115.44826.758536.30810@cargo.ozlabs.ibm.com","threadId":"9548","inReplyTo":"11872265153600-git-send-email-mdl123@verizon.net","subject":"Re: [PATCH] gitk: Fix warning when removing a branch (take 2)","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2007-08-16T01:57:46Z","receivedAt":"2007-08-16T01:57:46Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Mark Levedahl writes:\n\n> Paul - your commit b1054ac98 did not solve this for me. Playing around, I've\n> several times received errors like this when trying to delete a branch:\n> \n> can't read \"idheads(f7b9ebd595c954cd0803e6b6f1f0f96a966e04c9 a890c4fca84a2a5c7835fe6432ede3e7c4e5426b)\": no such element in array\n> can't read \"idheads(f7b9ebd595c954cd0803e6b6f1f0f96a966e04c9 a890c4fca84a2a5c7835fe6432ede3e7c4e5426b)\": no such element in array\n\nYeah, I missed that case.  Sorry.\n\n>     while executing\n> \"if {$idheads($dheads) eq $head} {\n\nI think\n\n\tif {[llength $dheads] == 1 && $idheads($dheads) eq $head} {\n\nshould be what we want.  Could you try that?\n\nPaul.\n"},{"id":"50878","messageId":"30e4a070708160446v5bdd177cn81553f5365b06460@mail.gmail.com","threadId":"9548","inReplyTo":"18115.44826.758536.30810@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] gitk: Fix warning when removing a branch (take 2)","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2007-08-16T11:46:46Z","receivedAt":"2007-08-16T11:46:46Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"On 8/15/07, Paul Mackerras <paulus@samba.org> wrote:\n> Mark Levedahl writes:\n>\n>\n> Yeah, I missed that case.  Sorry.\n>\n> >     while executing\n> > \"if {$idheads($dheads) eq $head} {\n>\n> I think\n>\n>         if {[llength $dheads] == 1 && $idheads($dheads) eq $head} {\n>\n> should be what we want.  Could you try that?\n>\n> Paul.\n\nThat works. Thanks.\n\nMark\n"}]}