[SR-Dev] commit emails gotchas

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Nov 20 13:43:09 CET 2008


The commit email script has some quirks that you should be aware of.

Some unexpected feature is that if you create a new branch
(git push origin my_branch:new_branch_that_does_not_exist_yet)
an email will be sent only for the last commit message in the branch.
If you update an existing branch or you don't care that only the last
commit will be emailed (the others will be emailed only if/when somebody
merges your branch in an existing branch), you can skip this.

Example:

git checkout -b my_branch master
vim file1
git add file1
git commit file1 

vim file2
git add file2
git commit file2

git push origin my_branch:tmp/my_new_branch

=> only the 2nd commit will be emailed to the list.

This happens because of the email comit script that tries to send
mail only for changes on the branch: it looks at the original branch
and at the new branch head and sends an email for all the commits
between them . However when creating a new branch, there is not enough
information to get the original branch and you either send emails for 
all the commits since project start (:-)) or only for the last one.

Even if that happen to you, all the commits messages will be sent the
first time you merge your new branch into some existing branch.

A way to avoid it in the first place is to first create a new branch,
e.g:
git checkout -b my_new_branch master
git push origin my_new_branch:tmp/my_new_branch

and then push your branch on it:
git checkout my_branch
git push origin my_branch:tmp/my_new_branch


Andrei



More information about the sr-dev mailing list