{"thread":{"id":"17295","subject":"post-receive-email - does not handle creating a new branch with same HEAD as other branch","startedAt":"2009-01-21T22:12:51Z","lastAt":"2009-01-21T22:12:51Z","messageCount":1,"participants":["Jake Goulding"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"101464","messageId":"49779DE3.8010906@vivisimo.com","threadId":"17295","inReplyTo":null,"subject":"post-receive-email - does not handle creating a new branch with same HEAD as other branch","fromName":"Jake Goulding","fromEmail":"goulding@vivisimo.com","sentAt":"2009-01-21T22:12:51Z","receivedAt":"2009-01-21T22:12:51Z","isPatch":false,"sender":{"key":"goulding@vivisimo.com","avatar":"https://gravatar.com/avatar/d8938ff226c618b80857e27f7e0a2d4335215bfb9733c321b8dd30c660b7f1e9?d=mp&s=160"},"body":"Given the simple case of two commits:\n\nA--B\n\nwith branches setup like:\nmaster: A\nb1: B\n\nIf I create a new branch b2 at the same point as b1 from a remote server:\n\n$ git push origin B:b2\n\nThe following code will be run in post-receive-email:\n\ngit rev-parse --not --branches |\ngrep -v $(git rev-parse $refname) |\ngit rev-list --pretty --stdin $newrev\n\n(refname = refs/heads/b2, newrev=B)\n\nThe problem occurs because the first rev-parse reports:\n\n^A\n^B\n^B\n\nAnd the grep removes lines matching B, leaving:\n\n^A\n\nwhich causes the eventual rev-list command to be:\n\ngit rev-list --pretty ^A B\n\nThis problem could be exaggerated if there were a lot of commits between\n A and B, which would cause each commit A..B to be reported.\n\nIs there any alternate way to write this command to cause these false\npositives to not be reported? I tried to write a version that uses the\nref name instead of the hash, but it did not end up very pretty (and I\ndon't think it worked...).\n\nThanks!\n\n-Jake\n"}]}