git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

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

Thoughts?

-- Phil Lawrence

Next: Andreas Schwab
Message 1 of 5 in “How can I tell if anything was fetched?”
  1. Phil LawrenceOct 11, 2012
  2. Andreas SchwabOct 11, 2012
  3. Enrico WeigeltOct 11, 2012
  4. Jeff KingOct 12, 2012
  5. Johannes SixtOct 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.