git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How can I tell if anything was fetched?
@ 2012-10-11 16:25 Phil Lawrence
  2012-10-11 16:45 ` Andreas Schwab
  2012-10-12  6:28 ` Johannes Sixt
  0 siblings, 2 replies; 5+ messages in thread
From: Phil Lawrence @ 2012-10-11 16:25 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-12  7:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-11 16:25 How can I tell if anything was fetched? Phil Lawrence
2012-10-11 16:45 ` Andreas Schwab
2012-10-11 18:29   ` Enrico Weigelt
2012-10-12  7:47   ` Jeff King
2012-10-12  6:28 ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).