开发者

git update hook: Finding all revs being committed

开发者 https://www.devze.com 2022-12-23 03:21 出处:网络
I\'m creating an update hook so that our central git repository can do some simple sanity checks of each file in each commit.However, I don\'t know how to make git cough up the names of all of the com

I'm creating an update hook so that our central git repository can do some simple sanity checks of each file in each commit. However, I don't know how to make git cough up the names of all of the commits in a "push".

No matter how many commits the client is pushing, the update hook is called just once (by design). For example, suppose that HEAD is e2706ec, and I create two commits:

$ echo 'date' >>foo && git commit -am'Touched foo'
[master e5c9682] Touched foo
 1 files changed, 1 insertions(+), 0 deletions(-)
$ echo 'date' >>bar && git commit -am'Touched bar'
[master bdc1fd1] Touched bar
 1 files changed, 1 insertions(+), 0 deletions(-)

Then I push the code to the central repository:

$ git push

The .git/hooks/update script gets called once with these arguments:

  • refs/heads/master
  • e2706ec31e51b9bbd4010e79fd7186089c59690e
  • bdc1fd17e8209bbb987b5358a0b49b20d9589103

Git passes to the update hook the ref_name, old_rev, and new_rev. What it doesn't pass are the names of any revs between old_rev and new_rev (in this case, e开发者_StackOverflow中文版5c9682).

Given old_rev and new_rev, what is the git spell to get each rev that the client is attempting to push?


git rev-list ^old_rev new_rev

It's list all commit between this two commit

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号