{"thread":{"id":"46676","subject":"Automatically delete branches containing accepted patches?","startedAt":"2017-08-27T18:44:15Z","lastAt":"2017-08-28T17:53:05Z","messageCount":5,"participants":["Lars Schneider","Jacob Keller","Nicolas Morey-Chaisemartin","Stefan Beller","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"327263","messageId":"8AF4A868-628B-42AE-B75E-4DF19F7C7A89@gmail.com","threadId":"46676","inReplyTo":null,"subject":"Automatically delete branches containing accepted patches?","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-08-27T18:44:06Z","receivedAt":"2017-08-27T18:44:15Z","isPatch":false,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"Hi,\n\nI have lots of git/git branches and once in a while some patches make it \ninto git/git master. If this happens I would like to delete my branch\nwith the patch automatically. That's not easily possible as the hashes \non my branches are, of course, not the same as the hashes on git/git.\n\nHow do you deal with this situation? Do you manually delete your \nbranches or do you have some clever script to share?\n\nThanks,\nLars\n"},{"id":"327272","messageId":"CA+P7+xok0bpgc7CwHB+vcLpODhjAkjgHq=cGZhmP+EpRvwSJzg@mail.gmail.com","threadId":"46676","inReplyTo":"8AF4A868-628B-42AE-B75E-4DF19F7C7A89@gmail.com","subject":"Re: Automatically delete branches containing accepted patches?","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-08-28T07:16:08Z","receivedAt":"2017-08-28T07:16:36Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Aug 27, 2017 at 11:44 AM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n> Hi,\n>\n> I have lots of git/git branches and once in a while some patches make it\n> into git/git master. If this happens I would like to delete my branch\n> with the patch automatically. That's not easily possible as the hashes\n> on my branches are, of course, not the same as the hashes on git/git.\n>\n> How do you deal with this situation? Do you manually delete your\n> branches or do you have some clever script to share?\n>\n> Thanks,\n> Lars\n\nYou might be able to use patch-ids and git-cherry, to see if similar\npatches (those with identical patch ids) are upstream. The patch id is\nonly calculated from the diff I believe, so it's mostly stable at\nleast as long as the contents didn't need to be changed to apply\nupstream. It's not 100% perfect, but it might help with what you're\nafter?\n\nThanks,\nJake\n"},{"id":"327273","messageId":"5c316336-19b4-c78e-6d14-001c2ff1c34c@suse.de","threadId":"46676","inReplyTo":"8AF4A868-628B-42AE-B75E-4DF19F7C7A89@gmail.com","subject":"Re: Automatically delete branches containing accepted patches?","fromName":"Nicolas Morey-Chaisemartin","fromEmail":"nmoreychaisemartin@suse.de","sentAt":"2017-08-28T07:44:27Z","receivedAt":"2017-08-28T07:44:33Z","isPatch":false,"sender":{"key":"nmoreychaisemartin@suse.de","avatar":"https://gravatar.com/avatar/5546322ccb9067f56b6939d9d5c758a40cab5b978b1379fd6ec8ab9b8a6a12b1?d=mp&s=160"},"body":"You could rebase your branches onto the upstream branch.\nOnce all the patches are in, the SHA1 of the rebased branch is somewhere in the history of the upstream master.\n\nI use a set of scripts I've written to handle multiple branches:\nhttps://github.com/nmorey/git-topic-branches\n\nUsing namesapce it knows which branch is against which ref. You can autorebase everythinmg. It'll tell you once everything is merged upstream:\n$ git auto-rebase  # alias for branch-autorebase\nREBASING: dev/cbuild-cleanup on origin/master\nREBASING FAILURE: dev/cbuild-cleanup on origin/master\nREBASING: dev/cbuild-return-code on origin/master\nREBASING: dev/suse-spec2 on origin/master\nINTEGRATED UPSTREAM: dev/suse-spec2 just made it into origin/master\nREBASING: dev/udev.md on origin/master\nINTEGRATED UPSTREAM: dev/udev.md just made it into origin/master\n\nYou should be able to either hook up something for auto deletion, or use the few helpers to detect the merged ones and delete them\n\n\nLe 27/08/2017 à 20:44, Lars Schneider a écrit :\n> Hi,\n>\n> I have lots of git/git branches and once in a while some patches make it \n> into git/git master. If this happens I would like to delete my branch\n> with the patch automatically. That's not easily possible as the hashes \n> on my branches are, of course, not the same as the hashes on git/git.\n>\n> How do you deal with this situation? Do you manually delete your \n> branches or do you have some clever script to share?\n>\n> Thanks,\n> Lars\n\n"},{"id":"327282","messageId":"CAGZ79kYKJo4hcBY=nEi6z2gSH=W322W_h3_68bb0ZzF+L8JUig@mail.gmail.com","threadId":"46676","inReplyTo":"8AF4A868-628B-42AE-B75E-4DF19F7C7A89@gmail.com","subject":"Re: Automatically delete branches containing accepted patches?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-08-28T17:32:37Z","receivedAt":"2017-08-28T17:32:48Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Aug 27, 2017 at 11:44 AM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n> Hi,\n>\n> I have lots of git/git branches and once in a while some patches make it\n> into git/git master. If this happens I would like to delete my branch\n> with the patch automatically. That's not easily possible as the hashes\n> on my branches are, of course, not the same as the hashes on git/git.\n>\n> How do you deal with this situation? Do you manually delete your\n> branches or do you have some clever script to share?\n\nAs soon as my patches are picked up, I rename my internal branch to\nbe the same as its remote counter part. Usually I rebase my local\nbranches on these remote branches, such that directly after queuing\nthey are identical.\n\nUsually I delete (local) branches as soon as I am either confident\nthey go in as is or they are not very interesting to me.\n(e.g. a one off typo fix is developed on detached HEAD, sent out\nand I forget about it. In case a discussion ensues, I have to either\ntake my patch or redo it. There is no local reminder of these things\nin the form of a branch)\n\nStefan\n\n> Thanks,\n> Lars\n"},{"id":"327284","messageId":"20170828175258.ssvohh5wljsg4clr@sigill.intra.peff.net","threadId":"46676","inReplyTo":"8AF4A868-628B-42AE-B75E-4DF19F7C7A89@gmail.com","subject":"Re: Automatically delete branches containing accepted patches?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-08-28T17:52:58Z","receivedAt":"2017-08-28T17:53:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Aug 27, 2017 at 08:44:06PM +0200, Lars Schneider wrote:\n\n> I have lots of git/git branches and once in a while some patches make it \n> into git/git master. If this happens I would like to delete my branch\n> with the patch automatically. That's not easily possible as the hashes \n> on my branches are, of course, not the same as the hashes on git/git.\n> \n> How do you deal with this situation? Do you manually delete your \n> branches or do you have some clever script to share?\n\nIt's definitely not a trivial problem.  I use a combination of three\nscripts/tricks:\n\n 1. I have a script[1] that uses git-cherry to see what's made it to\n    master or next. This isn't fool-proof, because sometimes minor\n    tweaks mean that the patch-ids differ. But it catches most cases.\n\n    [1] https://github.com/peff/git/blob/meta/merged\n\n 2. I aggressively rebase all of my topics. Basically when I sit down to\n    work each day, the first thing I run is a script[2] which\n    just loops over each topic, rebasing each against its master.\n\n    When topics have made it to master, this rebase produces an empty\n    output, and the script from (1) shows them as merged. The tricky\n    thing is that if a series touches the same area in multiple patches,\n    rebasing it on itself will often end up with conflicts in the early\n    patches. It's pretty easy to recognize this case and just \"rebase\n    --skip\" past the already-applied patches.\n\n    This also very occasionally results in a mis-merge where some little\n    tidbit of a patch is left (e.g., if I added a new block but it ended\n    up being moved elsewhere when Junio resolved a conflict, Git may\n    mis-apply the patch and end up with a duplicate block. For C code\n    this usually results in an error, but something like a duplicated\n    test can often go unnoticed).\n\n    [2] https://github.com/peff/git/blob/meta/rebase\n\n 3. I have a small wrapper[3] around for-each-ref that shows me my\n    topics in reverse authordate order. Reading it in that order reminds\n    me of what should be in-flight and might need prodding. This can\n    range from \"it was merged and I need to delete the local branch\" to\n    \"I sent it and it wasn't picked up for some reason\" to \"oops, I\n    forgot to send it\".\n\n    The script's pretty short and I suspect most of it could be done\n    with a \"git branch --format\" alias these days. The authordate\n    sorting is very important for me because I have dozens of ancient\n    crufty branches that are probably going nowhere but which I refuse\n    to delete. ;)\n\n    [3] https://github.com/peff/git/blob/meta/topics\n\nSo between the three of those, I generally eventually notice stale\nbranches lying around.\n\n-Peff\n"}]}