How can I tell if anything was fetched?
- From
Phil Lawrence <prlawrence@gmail.com>
- Date
- Oct 11, 2012, 16:25 UTC
- Message-ID
- <CAFRB3XkueafikCvwzBb+WOAG_1mEkVg1Yt6=teOuVwYd2zWVOw@mail.gmail.com>
I have a cron job that regularly fetches into a bare repo. Currently, the job then pushes the repo to another remote, regardless of whether or not anything was actually fetched. That's a waste.
What is the best way to know whether or not anything was received during the fetch? I don't want to be stuck trying to parse the answer out of STDOUT and STDERR...
One approach might be to first generate a state-of-the-repo SHA1:
# http://stackoverflow.com/a/7350019/834039
# http://git-scm.com/book/ch9-2.html
{
git rev-list --objects --all
git rev-list --objects -g --no-walk --all
git rev-list --objects --no-walk \
$(git fsck --unreachable |
grep '^unreachable commit' |
cut -d' ' -f3)
} | sort | uniq | git hash-object -w --stdinI could then do the git fetch, generate another state-of-the-repo SHA1 and compare...
Thoughts?
-- Phil Lawrence