git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Phil Lawrence <prlawrence@gmail.com>, git <git@vger.kernel.org>
Subject: Re: How can I tell if anything was fetched?
Date: Fri, 12 Oct 2012 03:47:39 -0400	[thread overview]
Message-ID: <20121012074739.GD17026@sigill.intra.peff.net> (raw)
In-Reply-To: <m28vbdkley.fsf@igel.home>

On Thu, Oct 11, 2012 at 06:45:09PM +0200, Andreas Schwab wrote:

> Phil Lawrence <prlawrence@gmail.com> writes:
> 
> > 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 think you'd only need to record the state of all refs (eg. the output
> of `git for-each-ref') to reliably detect any changes.

To clarify on the "only" in your sentence: it is not just that recording
the ref changes is more efficient. But recording the object state is
actively wrong. You might have fetched ref changes that do not introduce
new objects (e.g., a rewind of history, or a branch deletion). The
before-and-after ref state is both sufficient and necessary.  I suspect
you already realized that, Andreas, but I wanted to make sure it was
clear to readers, including the OP.

Checking ref state does suffer from potential race conditions with any
other simultaneous updates.  I don't think there is any reason we
couldn't have "git fetch" produce a machine-readable output detailing
what happened. We already have the same for "git push". I think it is
simply the case that nobody has really wanted it so far.

-Peff

  parent reply	other threads:[~2012-10-12  7:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2012-10-12  6:28 ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121012074739.GD17026@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=prlawrence@gmail.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).