{"thread":{"id":"20763","subject":"finding unmerged branches","startedAt":"2009-08-27T22:02:41Z","lastAt":"2009-08-28T02:08:26Z","messageCount":7,"participants":["Joey Hess","Avery Pennarun","Björn Steinbrink","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"121928","messageId":"20090827220241.GA1413@gnu.kitenet.net","threadId":"20763","inReplyTo":null,"subject":"finding unmerged branches","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2009-08-27T22:02:41Z","receivedAt":"2009-08-27T22:02:41Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"My situation is this: My project has a lot of remotes with\nlots of branches; about 250 branches in total. I want to\nfigure out which of these branches to look at to consider\nmerging.\n\nSo, I reach for git branch -a --no-merged master; that's what\nits man page says its for. But this still finds 120 branches,\nand a lot of them are not things I want to look at. Many of\nthem are copies of some of my own branches.\n\nWhat I really want is a way to find remote branches that\nare not merged with any of my local branches (or any origin\nbranches). A slow and stupid implementation of that is in the\nattached git-unmerged script, and it weeds the branch list\ndown to 68 branches, which are mostly really ones I might\nwant to look at.\n\nSo, three questions:\n\n* Is this situation somewhat common, or an I doing something wrong?\n  (Assuming that I have a good reason to want to look at remote \n  branches rather than waiting to get merge requests.)\n* Is there a better way to accomplish this than a slow perl script that\n  runs git branch -r --merged foreach of my branches?\n* Should git have something builtin to handle this case better?\n\n-- \nsee shy jo\n\n\n#!/usr/bin/perl\n\nmy @remote_branches = split ' ', `git branch -r | awk '{print $1}'`;\n\n# have to filter out the \"* \"\nmy @local_branches = split ' ', `git branch | sed 's/^..//'`;\n\nmy @origin_branches = grep /^origin\\//, @remote_branches;\n\nmy %unmerged = (map { $_ => 1 } @remote_branches),\n\t(map { $_ => 0 } @local_branches, @origin_branches);\n\nforeach my $branch (@local_branches, @origin_branches) {\n\tmap { $unmerged{$_}=0 } split ' ', `git branch -r --merged \"$branch\" | awk '{print $1}'`\n}\n\nforeach my $branch (sort keys %unmerged) {\n\tprint \"$branch\\n\" if $unmerged{$branch};\n}\n"},{"id":"121932","messageId":"32541b130908271522u1048dcb1h67b79049e46df1ac@mail.gmail.com","threadId":"20763","inReplyTo":"20090827220241.GA1413@gnu.kitenet.net","subject":"Re: finding unmerged branches","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2009-08-27T22:22:55Z","receivedAt":"2009-08-27T22:22:55Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Thu, Aug 27, 2009 at 10:02 PM, Joey Hess<joey@kitenet.net> wrote:\n> What I really want is a way to find remote branches that\n> are not merged with any of my local branches (or any origin\n> branches). A slow and stupid implementation of that is in the\n> attached git-unmerged script, and it weeds the branch list\n> down to 68 branches, which are mostly really ones I might\n> want to look at.\n\nHow about:\n\ngitk $(git for-each-ref --format='%(refname)' 'refs/remotes/'; git\nfor-each-ref --format='^%(refname)' 'refs/heads/')\n\nYou could also replace 'gitk' with 'git log', and mess with the\n--pretty=format:whatever parameter.\n\nHave fun,\n\nAvery\n"},{"id":"121934","messageId":"20090827223504.GA18307@atjola.homenet","threadId":"20763","inReplyTo":"20090827220241.GA1413@gnu.kitenet.net","subject":"Re: finding unmerged branches","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-08-27T22:35:04Z","receivedAt":"2009-08-27T22:35:04Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.08.27 18:02:41 -0400, Joey Hess wrote:\n> My situation is this: My project has a lot of remotes with\n> lots of branches; about 250 branches in total. I want to\n> figure out which of these branches to look at to consider\n> merging.\n> \n> So, I reach for git branch -a --no-merged master; that's what\n> its man page says its for. But this still finds 120 branches,\n> and a lot of them are not things I want to look at. Many of\n> them are copies of some of my own branches.\n> \n> What I really want is a way to find remote branches that\n> are not merged with any of my local branches (or any origin\n> branches). A slow and stupid implementation of that is in the\n> attached git-unmerged script, and it weeds the branch list\n> down to 68 branches, which are mostly really ones I might\n> want to look at.\n> \n> So, three questions:\n> \n> * Is this situation somewhat common, or an I doing something wrong?\n>   (Assuming that I have a good reason to want to look at remote \n>   branches rather than waiting to get merge requests.)\n> * Is there a better way to accomplish this than a slow perl script that\n>   runs git branch -r --merged foreach of my branches?\n\nHm, not sure if I'd call it \"better\", but probably at least a bit\nfaster. You could create a \"fake\" merge to combine all the branches.\n\ngit branch -r --no-merged $(\n  : | git commit-tree HEAD^{tree} $(\n    git for-each-ref --format='-p %(refname)' \\\n      refs/heads/ \\\n      refs/remotes/origin\n    )\n  )\n\nBjörn\n"},{"id":"121939","messageId":"7vd46gn8kn.fsf@alter.siamese.dyndns.org","threadId":"20763","inReplyTo":"20090827223504.GA18307@atjola.homenet","subject":"Re: finding unmerged branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-27T23:25:12Z","receivedAt":"2009-08-27T23:25:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> writes:\n\n> Hm, not sure if I'd call it \"better\", but probably at least a bit\n> faster. You could create a \"fake\" merge to combine all the branches.\n>\n> git branch -r --no-merged $(\n>   : | git commit-tree HEAD^{tree} $(\n>     git for-each-ref --format='-p %(refname)' \\\n>       refs/heads/ \\\n>       refs/remotes/origin\n>     )\n>   )\n\nHeh, that is certainly a cute hack ;-)\n"},{"id":"121943","messageId":"20090828004450.GA20964@gnu.kitenet.net","threadId":"20763","inReplyTo":"20090827223504.GA18307@atjola.homenet","subject":"Re: finding unmerged branches","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2009-08-28T00:44:50Z","receivedAt":"2009-08-28T00:44:50Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Björn Steinbrink wrote:\n> Hm, not sure if I'd call it \"better\", but probably at least a bit\n> faster. You could create a \"fake\" merge to combine all the branches.\n> \n> git branch -r --no-merged $(\n>   : | git commit-tree HEAD^{tree} $(\n>     git for-each-ref --format='-p %(refname)' \\\n>       refs/heads/ \\\n>       refs/remotes/origin\n>     )\n>   )\n\nThat does run fast. Has some warnings about duplicate parents. The gitk\nmethod seems more useful.\n\n-- \nsee shy jo\n"},{"id":"121944","messageId":"20090828005420.GB20964@gnu.kitenet.net","threadId":"20763","inReplyTo":"32541b130908271522u1048dcb1h67b79049e46df1ac@mail.gmail.com","subject":"Re: finding unmerged branches","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2009-08-28T00:54:20Z","receivedAt":"2009-08-28T00:54:20Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Avery Pennarun wrote:\n> How about:\n> \n> gitk $(git for-each-ref --format='%(refname)' 'refs/remotes/'; git\n> for-each-ref --format='^%(refname)' 'refs/heads/')\n> \n> You could also replace 'gitk' with 'git log', and mess with the\n> --pretty=format:whatever parameter.\n\nI added 'refs/remotes/origin/' 'refs/tags/' to the list, and that's\nalmost perfect, thanks.\n\nThough there was one remote branch where gitk showed a lot of commits\nfrom origin/master before the unmerged changes in the branch. Could not\nfigure out why, git log doesn't show them.\n\n-- \nsee shy jo\n"},{"id":"121949","messageId":"20090828020826.GA28782@gnu.kitenet.net","threadId":"20763","inReplyTo":"20090827220241.GA1413@gnu.kitenet.net","subject":"Re: finding unmerged branches","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2009-08-28T02:08:26Z","receivedAt":"2009-08-28T02:08:26Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Joey Hess wrote:\n> * Is this situation somewhat common, or an I doing something wrong?\n>   (Assuming that I have a good reason to want to look at remote \n>   branches rather than waiting to get merge requests.)\n\nCome to think, the github fork queue serves basically the same purpose,\nbut only for branches in github.\n\n-- \nsee shy jo\n"}]}