I'm struggling to write a pre-receive hook which should verify push basing on existence of marker file. But newref
populated by script is pointing into nowhere.
I can`t get any data to validate getting:
remote: fatal: bad object 3bb1ab6de84c324cd2fb0a7961bd5afccfd77d55
I`m trying to acquire data by:
git show $newrev
I tried also:
list_commits=git rev-list $oldrev..$newrev
but only got:
remote: fatal: Invalid revision range 341cc54a0afa8824e6f61514d6709b5f71f2c444..cc6c92ef2af267bc228219216078e0b1b3b7b2bb
When I ran git log there was not any of pushed commits.
How do I get access to them?
I have repository on Atlassian Bitbucket v5.1.0 maybe it is the case? If yes, do you know any workarounds?
Whole pre-receive script for now:
#!/bin/bash
while read oldrev newrev refname;
do
git show $newrev
done
EDIT:
Thanks to info I`ve found here https://git.seveas.net/manpages/gitrepository-layout.html to make object file discoverable you have to edit objects/info/alternates file by adding folder name, which home by default is object folder.
F.e. to add incoming-b2241(pushed changes) which is in .git/objects you need to add only incoming-b2241 into alternates
After this incoming objects are accessible for git cat-file and so.
Don`t forget to re-edit it afterwards, as non-existing directories will corrupt repository, but luckily errors are pretty descriptive and then you know what need to be fixed.