git/list[1] front-page[2] threads[3] people[4] search[5] about
 

post-receive-email - does not handle creating a new branch with same HEAD as other branch

From
Jake Goulding <goulding@vivisimo.com>
Date
Jan 21, 2009, 22:12 UTC
Message-ID
<49779DE3.8010906@vivisimo.com>
Given the simple case of two commits:
A--B

with branches setup like: master: A b1: B

If I create a new branch b2 at the same point as b1 from a remote server:
$ git push origin B:b2
The following code will be run in post-receive-email:

git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --pretty --stdin $newrev

(refname = refs/heads/b2, newrev=B)
The problem occurs because the first rev-parse reports:

^A ^B ^B

And the grep removes lines matching B, leaving:
^A
which causes the eventual rev-list command to be:
git rev-list --pretty ^A B
This problem could be exaggerated if there were a lot of commits between
 A and B, which would cause each commit A..B to be reported.

Is there any alternate way to write this command to cause these false positives to not be reported? I tried to write a version that uses the ref name instead of the hash, but it did not end up very pretty (and I don't think it worked...).

Thanks!
-Jake
Message 1 of 1 in “post-receive-email - does not handle creating a new branch with same HEAD as other branch”
  1. Jake GouldingJan 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.