{"thread":{"id":"30037","subject":"Listing commits that are _exclusively_ available on a given branch","startedAt":"2012-03-23T14:36:33Z","lastAt":"2012-03-23T19:39:50Z","messageCount":5,"participants":["Johan Herland","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"187571","messageId":"CALKQrge-=XExhwxuC14uynpuuO3W+f4YO4=X7kFUx33F3HtnyQ@mail.gmail.com","threadId":"30037","inReplyTo":null,"subject":"Listing commits that are _exclusively_ available on a given branch","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2012-03-23T14:36:33Z","receivedAt":"2012-03-23T14:36:33Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Hi,\n\nI'm trying to figure out how to list commits on a given branch that\nare not available on any other branch, i.e. the commits that are\nexclusive to my branch.\n\nSo far I only have this somewhat brute-force alternative:\n\n  git rev-list refs/heads/mybranch --not $(git show-ref --heads | grep\n-v refs/heads/mybranch)\n\nIs it possible to phrase this query in a simpler manner? Preferably by\nnot having to list all refs and then run grep on it...\n\n(I've already tried playing around with \"git show-branch\" and its\noptions, but to no avail.)\n\n\nHave fun! :)\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"187580","messageId":"20120323170640.GA12881@sigill.intra.peff.net","threadId":"30037","inReplyTo":"CALKQrge-=XExhwxuC14uynpuuO3W+f4YO4=X7kFUx33F3HtnyQ@mail.gmail.com","subject":"Re: Listing commits that are _exclusively_ available on a given branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-23T17:06:41Z","receivedAt":"2012-03-23T17:06:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 23, 2012 at 03:36:33PM +0100, Johan Herland wrote:\n\n> I'm trying to figure out how to list commits on a given branch that\n> are not available on any other branch, i.e. the commits that are\n> exclusive to my branch.\n> \n> So far I only have this somewhat brute-force alternative:\n> \n>   git rev-list refs/heads/mybranch --not $(git show-ref --heads | grep\n> -v refs/heads/mybranch)\n> \n> Is it possible to phrase this query in a simpler manner? Preferably by\n> not having to list all refs and then run grep on it...\n\nNo, I think that is the only way to do it. The algorithm run by rev-list\nin that case should be optimal, so there is nothing to improve there.\nSyntactically, it's a little bit of a pain because there is no way to\ntell rev-list \"--all, except for this one branch\" short of using grep.\nWe could add a new syntax for that, but I'm not sure what it would look\nlike (or if it would be any easier on the eyes than what you have).\n\nYou might consider using \"git rev-list --stdin\" to avoid running into\nlimits on the command-line length.\n\n-Peff\n"},{"id":"187587","messageId":"7vaa37usiv.fsf@alter.siamese.dyndns.org","threadId":"30037","inReplyTo":"20120323170640.GA12881@sigill.intra.peff.net","subject":"Re: Listing commits that are _exclusively_ available on a given branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-23T17:38:32Z","receivedAt":"2012-03-23T17:38:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> No, I think that is the only way to do it. The algorithm run by rev-list\n> in that case should be optimal, so there is nothing to improve there.\n> Syntactically, it's a little bit of a pain because there is no way to\n> tell rev-list \"--all, except for this one branch\" short of using grep.\n> We could add a new syntax for that, but I'm not sure what it would look\n> like (or if it would be any easier on the eyes than what you have).\n\nWe discussed --exclude-refs=\"refs/tags/expermental-*\" that would affect\nhow --all, --heads, and friends are processed several weeks ago, didn't\nwe?\n"},{"id":"187591","messageId":"20120323175007.GA13410@sigill.intra.peff.net","threadId":"30037","inReplyTo":"7vaa37usiv.fsf@alter.siamese.dyndns.org","subject":"Re: Listing commits that are _exclusively_ available on a given branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-23T17:50:07Z","receivedAt":"2012-03-23T17:50:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 23, 2012 at 10:38:32AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > No, I think that is the only way to do it. The algorithm run by rev-list\n> > in that case should be optimal, so there is nothing to improve there.\n> > Syntactically, it's a little bit of a pain because there is no way to\n> > tell rev-list \"--all, except for this one branch\" short of using grep.\n> > We could add a new syntax for that, but I'm not sure what it would look\n> > like (or if it would be any easier on the eyes than what you have).\n> \n> We discussed --exclude-refs=\"refs/tags/expermental-*\" that would affect\n> how --all, --heads, and friends are processed several weeks ago, didn't\n> we?\n\nGmane seems to be down at the moment, but I think the thread you are\ntalking about can be found here:\n\n  http://mid.gmane.org/7v4nuvghfk.fsf@alter.siamese.dyndns.org\n  http://mid.gmane.org/4F391F5C.1000400@alum.mit.edu\n  http://mid.gmane.org/7vaa4meat5.fsf@alter.siamese.dyndns.org\n\nIt talks about excluding from the positive side, like:\n\n  git rev-list --all --exclude-ref=refs/heads/foo\n\nThat can also be extended to the negative side, like:\n\n  git rev-list refs/heads/foo --not --all --exclude-ref=refs/heads/foo\n\nthough it is slightly confusing to read due to the double negation (you\nare \"--not\" \"--exclude\"-ing the ref). However, I think the double\nnegation is necessary (i.e., you could not say \"--include-ref\"), because\nthe two negations are talking about two different things (one is about\nlimiting the list of items fed to the graph traversal, and the other is\nabout limiting the graph traversal itself).\n\nSo yeah, I think that would work. But AFAIK, there has been no other\nactivity on that topic.\n\n-Peff\n"},{"id":"187606","messageId":"7v4ntft8c9.fsf@alter.siamese.dyndns.org","threadId":"30037","inReplyTo":"20120323175007.GA13410@sigill.intra.peff.net","subject":"Re: Listing commits that are _exclusively_ available on a given branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-23T19:39:50Z","receivedAt":"2012-03-23T19:39:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, Mar 23, 2012 at 10:38:32AM -0700, Junio C Hamano wrote:\n>\n>> Jeff King <peff@peff.net> writes:\n>> \n>> > No, I think that is the only way to do it. The algorithm run by rev-list\n>> > in that case should be optimal, so there is nothing to improve there.\n>> > Syntactically, it's a little bit of a pain because there is no way to\n>> > tell rev-list \"--all, except for this one branch\" short of using grep.\n>> > We could add a new syntax for that, but I'm not sure what it would look\n>> > like (or if it would be any easier on the eyes than what you have).\n>> \n>> We discussed --exclude-refs=\"refs/tags/expermental-*\" that would affect\n>> how --all, --heads, and friends are processed several weeks ago, didn't\n>> we?\n>\n> Gmane seems to be down at the moment, but I think the thread you are\n> talking about can be found here:\n>\n>   http://mid.gmane.org/7v4nuvghfk.fsf@alter.siamese.dyndns.org\n>   http://mid.gmane.org/4F391F5C.1000400@alum.mit.edu\n>   http://mid.gmane.org/7vaa4meat5.fsf@alter.siamese.dyndns.org\n>\n> It talks about excluding from the positive side, like:\n>\n>   git rev-list --all --exclude-ref=refs/heads/foo\n>\n> That can also be extended to the negative side, like:\n>\n>   git rev-list refs/heads/foo --not --all --exclude-ref=refs/heads/foo\n>\n> though it is slightly confusing to read due to the double negation (you\n> are \"--not\" \"--exclude\"-ing the ref).\n\nThe confusion comes only if you do not differentiate two independent\nconcepts, I think.  --all and --exclude-ref are about what the starting\npoints of the traversal (i.e. what we would call add_rev_cmdline() and\nadd_pending_sha1() with), and --not is about the color in which these\npending objects will be painted.\n\nThe callpath leading to revisions.c::handle_one_ref() from setup_revisions()\nmust be revamped, so that \"--all\" does not immediately put them directly\nin the pending array, but later \"--exclude-ref\" can subtract from the set,\nbefore the starting points are determined and painted in their colors,\nonce we add --exclude-ref support.\n"}]}