How can I tell if anything was fetched?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 --stdin

I could then do the git fetch, generate another state-of-the-repo SHA1
and compare...

Thoughts?

--
Phil Lawrence
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]