git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jacob Keller <jacob.keller@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	Git mailing list <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 1/1] refspec: add support for negative refspecs
Date: Wed, 30 Sep 2020 13:49:53 -0700	[thread overview]
Message-ID: <CA+P7+xpDoqspwEG_PABvP33FL-+mo6zXvWxf5FKOiSrydXjBKQ@mail.gmail.com> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2009301428580.50@tvgsbejvaqbjf.bet>

On Wed, Sep 30, 2020 at 5:36 AM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Jake,
>
> On Fri, 25 Sep 2020, Jacob Keller wrote:
>
> > diff --git a/remote.c b/remote.c
> > index eafc14cbe759..26a127142344 100644
> > --- a/remote.c
> > +++ b/remote.c
> > @@ -682,6 +682,91 @@ static int match_name_with_pattern(const char *key, const char *name,
> >       return ret;
> >  }
> >
> > +static int refspec_match(const struct refspec_item *refspec,
> > +                      const char *name)
> > +{
> > +     if (refspec->pattern)
> > +             return match_name_with_pattern(refspec->src, name, NULL, NULL);
> > +
> > +     return !strcmp(refspec->src, name);
> > +}
> > +
> > +static int omit_name_by_refspec(const char *name, struct refspec *rs)
> > +{
> > +     int i;
> > +
> > +     for (i = 0; i < rs->nr; i++) {
> > +             if (rs->items[i].negative && refspec_match(&rs->items[i], name))
> > +                     return 1;
> > +     }
> > +     return 0;
> > +}
> > +
> > +struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
> > +{
> > +     struct ref **tail;
> > +
> > +     for (tail = &ref_map; *tail; ) {
> > +             struct ref *ref = *tail;
> > +
> > +             if (omit_name_by_refspec(ref->name, rs)) {
> > +                     *tail = ref->next;
> > +                     free(ref->peer_ref);
> > +                     free(ref);
> > +             } else
> > +                     tail = &ref->next;
> > +     }
> > +
> > +     return ref_map;
> > +}
> > +
> > +static int query_matches_negative_refspec(struct refspec *rs, struct refspec_item *query)
> > +{
> > +     int i, matched_negative = 0;
> > +     int find_src = !query->src;
> > +     struct string_list reversed = STRING_LIST_INIT_NODUP;
> > +     const char *needle = find_src ? query->dst : query->src;
> > +
> > +     /*
> > +      * Check whether the queried ref matches any negative refpsec. If so,
> > +      * then we should ultimately treat this as not matching the query at
> > +      * all.
> > +      *
> > +      * Note that negative refspecs always match the source, but the query
> > +      * item uses the destination. To handle this, we apply pattern
> > +      * refspecs in reverse to figure out if the query source matches any
> > +      * of the negative refspecs.
> > +      */
> > +     for (i = 0; i < rs->nr; i++) {
> > +             struct refspec_item *refspec = &rs->items[i];
> > +             char *expn_name;
> > +
> > +             if (refspec->negative)
> > +                     continue;
> > +
> > +             /* Note the reversal of src and dst */
> > +             if (refspec->pattern) {
> > +                     const char *key = refspec->dst ?: refspec->src;
>
> Would you mind fixing this? This keeps getting reverted...
>

Ack.... I swore I fixed this... I'm not sure what happened on my end here.

  reply	other threads:[~2020-09-30 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 21:07 [PATCH v3 0/1] implement negative refspecs Jacob Keller
2020-09-25 21:07 ` [PATCH v3 1/1] refspec: add support for " Jacob Keller
2020-09-29 21:21   ` Junio C Hamano
2020-09-30 12:36   ` Johannes Schindelin
2020-09-30 20:49     ` Jacob Keller [this message]
2020-09-30 21:05       ` Junio C Hamano
2020-09-30 21:06         ` Jacob Keller

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CA+P7+xpDoqspwEG_PABvP33FL-+mo6zXvWxf5FKOiSrydXjBKQ@mail.gmail.com \
    --to=jacob.keller@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.e.keller@intel.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).