From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Shawn Pearce <spearce@spearce.org>,
Michael J Gruber <git@drmicha.warpmail.net>,
git@vger.kernel.org
Subject: Re: [RFC/PATCH] fetch: bigger forced-update warnings
Date: Wed, 7 Sep 2011 17:57:00 -0400 [thread overview]
Message-ID: <20110907215700.GA27292@sigill.intra.peff.net> (raw)
In-Reply-To: <7vty8o10kj.fsf@alter.siamese.dyndns.org>
On Wed, Sep 07, 2011 at 02:53:32PM -0700, Junio C Hamano wrote:
> > Some branches are expected to rewind, so the prominent
> > warning would be annoying. However, git doesn't know what
> > the expectation is for a particular branch. We can have it
> > guess by peeking at the lost couple of reflog entries. If we
>
> s/lost/last/
Oops, thanks.
> This is slightly offtopic, but I have been wondering if this approach do
> the right thing for "git pull". Wouldn't the underlying "git fetch" give a
> warning, and then the calling "git pull" go ahead and make a merge,
> scrolling the warning away with the merge/update summary diffstat? That
> would be a larger change if "git pull" needs to stash away the warning
> message, do its thing and then spit out the warning later.
I think this particular warning has nothing to do with git-pull. But
rather, that we should _always_ abort a pull with a forced-update.
Because the only sane things to do there are:
1. Stop and look around, and see if you should be doing a "git reset"
first.
or
2. "git pull --rebase"
But proceeding with the pull just seems like a disaster. So it is not
about "this usually fast forwards, but isn't now, so let's make the
warning bigger". It is more about noticing that it is a forced-update at
all. Maybe that's what you meant by "off-topic". :)
> > +static int forced_update_is_uncommon(const char *ref)
> > +{
> > + struct update_counts uc;
> > + memset(&uc, 0, sizeof(&uc));
> > + if (for_each_recent_reflog_ent(ref, count_updates, 4096, &uc) < 0)
> > + for_each_reflog_ent(ref, count_updates, &uc);
> > + return uc.fastforward && uc.forced <= 1; /* 1 for the one we just did */
> > +}
>
> Looks sensible.
Now we just need to paint the shed. :)
-Peff
next prev parent reply other threads:[~2011-09-07 21:57 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-01 18:25 Dropping '+' from fetch = +refs/heads/*:refs/remotes/origin/*? Junio C Hamano
2011-09-01 18:39 ` Junio C Hamano
2011-09-01 19:14 ` Shawn Pearce
2011-09-01 19:20 ` Michael J Gruber
2011-09-01 19:35 ` Matthieu Moy
2011-09-01 19:50 ` Shawn Pearce
2011-09-02 5:55 ` Matthieu Moy
2011-09-02 0:00 ` Jeff King
2011-09-02 7:00 ` Johannes Sixt
2011-09-02 15:26 ` Jeff King
2011-09-02 7:42 ` Michael J Gruber
2011-09-02 15:29 ` Jeff King
2011-09-02 16:14 ` Junio C Hamano
2011-09-02 16:25 ` Jeff King
2011-09-02 16:47 ` Junio C Hamano
2011-09-05 18:15 ` Shawn Pearce
2011-09-05 20:47 ` Jeff King
2011-09-05 20:53 ` Shawn Pearce
2011-09-05 20:57 ` Jeff King
2011-09-05 21:14 ` Shawn Pearce
2011-09-07 21:20 ` [RFC/PATCH] fetch: bigger forced-update warnings Jeff King
2011-09-07 21:39 ` Shawn Pearce
2011-09-07 21:53 ` Junio C Hamano
2011-09-07 21:57 ` Jeff King [this message]
2011-09-07 22:42 ` Thomas Rast
2011-09-06 7:39 ` Dropping '+' from fetch = +refs/heads/*:refs/remotes/origin/*? Matthieu Moy
2011-09-06 7:51 ` Michael J Gruber
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=20110907215700.GA27292@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=spearce@spearce.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).