From: "Carlos Martín Nieto" <cmn@elego.de>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
mathstuf@gmail.com
Subject: Re: [PATCH 2/3] fetch: honor the user-provided refspecs when pruning refs
Date: Fri, 07 Oct 2011 18:37:13 +0200 [thread overview]
Message-ID: <1318005433.4579.5.camel@centaur.lab.cmartin.tk> (raw)
In-Reply-To: <20111007162625.GB4399@sigill.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 2471 bytes --]
On Fri, 2011-10-07 at 12:26 -0400, Jeff King wrote:
> On Thu, Oct 06, 2011 at 11:21:46PM +0200, Carlos Martín Nieto wrote:
>
> > If the user gave us refspecs on the command line, we should use those
> > when deciding whether to prune a ref instead of relying on the
> > refspecs in the config.
> >
> > Previously, running
> >
> > git fetch --prune origin refs/heads/master:refs/remotes/origin/master
> >
> > would delete every other tag under the origin namespace because we
>
> I assume you mean s/tag/branch/ in the last line?
Yeah, maybe ref would be better?
>
> > ---
> > builtin/fetch.c | 6 ++--
> > builtin/remote.c | 2 +-
> > remote.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++-----
> > remote.h | 3 +-
> > 4 files changed, 77 insertions(+), 12 deletions(-)
>
> Tests?
Good point.
>
> > static int get_stale_heads_cb(const char *refname,
> > const unsigned char *sha1, int flags, void *cb_data)
> > {
> > struct stale_heads_info *info = cb_data;
> > struct refspec refspec;
> > + int ret;
> > memset(&refspec, 0, sizeof(refspec));
> > refspec.dst = (char *)refname;
> > - if (!remote_find_tracking(info->remote, &refspec)) {
> > - if (!((flags & REF_ISSYMREF) ||
> > - string_list_has_string(info->ref_names, refspec.src))) {
> > - struct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);
> > - hashcpy(ref->new_sha1, sha1);
> > - }
> > +
> > + /*
> > + * If the user speicified refspecs on the command line, we
> > + * should only use those to check. Otherwise, look in the
> > + * remote's configuration for the branch.
> > + */
> > + if (info->ref_count)
> > + ret = find_in_refs(info->refs, info->ref_count, &refspec);
> > + else
> > + ret = remote_find_tracking(info->remote, &refspec);
>
> Minor typo in the comment. But more importantly, this feels like a very
> low-level place to be thinking about things like what the user gave us
> on the command line.
>
> Shouldn't get_stale_heads not get a remote at all, and just get a set of
> refspecs? Those should be the minimal information it needs to get its
> answer, right?
OK, so take a step back and figure out what we want the rules to be
before we call get_stale_heads. It does sound like a more elegant
approach. I was trying to disrupt the callers as little as possible, but
then again, there's only two. Will change.
cmn
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2011-10-07 16:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-06 20:19 [PATCH 0/3] Be more careful when prunning Carlos Martín Nieto
2011-10-06 20:19 ` [PATCH 1/3] fetch: free all the additional refspecs Carlos Martín Nieto
2011-10-06 20:19 ` [PATCH 2/3] fetch: honor the user-provided refspecs when pruning refs Carlos Martín Nieto
2011-10-06 20:19 ` [PATCH 3/3] fetch: treat --tags like refs/tags/*:refs/tags/* when pruning Carlos Martín Nieto
2011-10-06 20:51 ` [PATCH 0/3] Be more careful when prunning Ben Boeckel
2011-10-06 20:58 ` Carlos Martín Nieto
2011-10-06 21:21 ` [PATCHv2 " Carlos Martín Nieto
2011-10-06 21:21 ` [PATCH 1/3] fetch: free all the additional refspecs Carlos Martín Nieto
2011-10-06 21:21 ` [PATCH 2/3] fetch: honor the user-provided refspecs when pruning refs Carlos Martín Nieto
2011-10-07 16:26 ` Jeff King
2011-10-07 16:37 ` Carlos Martín Nieto [this message]
2011-10-07 16:39 ` Jeff King
2011-10-06 21:21 ` [PATCH 3/3] fetch: treat --tags like refs/tags/*:refs/tags/* when pruning Carlos Martín Nieto
2011-10-07 16:33 ` Jeff King
2011-10-07 16:40 ` Carlos Martín Nieto
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=1318005433.4579.5.camel@centaur.lab.cmartin.tk \
--to=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mathstuf@gmail.com \
--cc=peff@peff.net \
/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).