Git post-fetch hook and multiple commits in one click

I'm trying to figure out what's going on in git after being received when multiple commits are pushed together. From the documentation and examples I've seen, I expect it to accept a list of links from STDIN, which will allow me to take action on a per-commit basis, but doesn't seem to work like that? Here's what I have:

My post-trick is obviously just for testing:

#!/usr/bin/perl

use Data::Dumper;
my @input = <STDIN>;    
print STDERR Dumper(\@input);

      

I edit two files and commit them separately:

nelson% git log origin/master..HEAD
commit 93f96201f2cfd3e83a9a609ec644dc873aefeb17
Author: cecukemon <cecukemon@...>
Date:   Thu May 28 11:09:19 2015 +0200

    commit 2

commit 8bbcc8370101d44c8a7302fb365f257e62a61e9d
Author: cecukemon <cecukemon@...>
Date:   Thu May 28 11:09:09 2015 +0200

    commit 1

      

Push them as one:

nelson% git push
Counting objects: 6, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 542 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: $VAR1 = [
remote:           'fa45b972bb59fbe92d7331cfad5d2933a53414ce 93f96201f2cfd3e83a9a609ec644dc873aefeb17 refs/heads/master
remote: '
remote:         ];
To /home/cecukemon/hooktest
   fa45b97..93f9620  master -> master

      

Both commits were successfully pushed:

nelson% git log origin/master..HEAD
nelson%

      

and successfully running the hook after receiving, but I only see one of the commits in the link list ($ VAR1 in the push output).

Am I fundamentally misunderstanding how post-foster hooks work?

+3


source to share


1 answer


You get old and new ref values, so if multiple commits have been added, you can usually get them with $old..$new

(eg commited git rev-list

).



while read old new ref; do
        while read commit; do
                # check the commit here
        done <<EOD
$(git rev-list $old..$new)
EOD

      

+3


source







All Articles