All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 05/24] dir.c: remove an implicit dependency on the_index in pathspec code
Date: Mon, 13 Aug 2018 10:17:18 -0700	[thread overview]
Message-ID: <20180813171718.GB240194@google.com> (raw)
In-Reply-To: <20180813161441.16824-6-pclouds@gmail.com>

On 08/13, Nguyễn Thái Ngọc Duy wrote:
> diff --git a/dir.c b/dir.c
> index 29fbbd48c8..e25aed013b 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -276,12 +276,13 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
>  #define DO_MATCH_DIRECTORY (1<<1)
>  #define DO_MATCH_SUBMODULE (1<<2)
>  
> -static int match_attrs(const char *name, int namelen,
> +static int match_attrs(const struct index_state *istate,
> +		       const char *name, int namelen,
>  		       const struct pathspec_item *item)
>  {
>  	int i;
>  
> -	git_check_attr(&the_index, name, item->attr_check);
> +	git_check_attr(istate, name, item->attr_check);
>  	for (i = 0; i < item->attr_match_nr; i++) {
>  		const char *value;
>  		int matched;
> @@ -318,7 +319,8 @@ static int match_attrs(const char *name, int namelen,
>   *
>   * It returns 0 when there is no match.
>   */
> -static int match_pathspec_item(const struct pathspec_item *item, int prefix,
> +static int match_pathspec_item(const struct index_state *istate,
> +			       const struct pathspec_item *item, int prefix,
>  			       const char *name, int namelen, unsigned flags)
>  {
>  	/* name/namelen has prefix cut off by caller */
> @@ -358,7 +360,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
>  	    strncmp(item->match, name - prefix, item->prefix))
>  		return 0;
>  
> -	if (item->attr_match_nr && !match_attrs(name, namelen, item))
> +	if (item->attr_match_nr && !match_attrs(istate, name, namelen, item))
>  		return 0;

Yuck, all of this just because I added the ability to match against
attrs with pathspecs.  Part of me wonders if it would be better to put a
pointer to the needed istate in the pathspec struct...but then I can
think of a ton of reasons why that wouldn't be good either.

So yes I think this is probably the right approach, I'm just sorry I
made it this messy :/


-- 
Brandon Williams

  reply	other threads:[~2018-08-13 17:17 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-13 16:14 [PATCH 00/24] Kill the_index part3 Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 01/24] diff.c: move read_index() code back to the caller Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 02/24] cache-tree: wrap the_index based wrappers with #ifdef Nguyễn Thái Ngọc Duy
2018-08-13 21:18   ` Junio C Hamano
2018-08-13 16:14 ` [PATCH 03/24] attr: remove an implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-08-13 17:12   ` Brandon Williams
2018-08-13 16:14 ` [PATCH 04/24] convert.c: " Nguyễn Thái Ngọc Duy
2018-08-13 21:21   ` Junio C Hamano
2018-08-13 16:14 ` [PATCH 05/24] dir.c: remove an implicit dependency on the_index in pathspec code Nguyễn Thái Ngọc Duy
2018-08-13 17:17   ` Brandon Williams [this message]
2018-08-13 18:40     ` Duy Nguyen
2018-08-13 16:14 ` [PATCH 06/24] preload-index.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 07/24] ls-files: correct index argument to get_convert_attr_ascii() Nguyễn Thái Ngọc Duy
2018-08-15 18:56   ` Stefan Beller
2018-08-13 16:14 ` [PATCH 08/24] unpack-trees: remove 'extern' on function declaration Nguyễn Thái Ngọc Duy
2018-08-15 19:10   ` Stefan Beller
2018-08-15 19:21     ` Duy Nguyen
2018-08-15 19:25       ` Stefan Beller
2018-08-13 16:14 ` [PATCH 09/24] unpack-trees: add a note about path invalidation Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 10/24] unpack-trees: don't shadow global var the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 11/24] unpack-trees: convert clear_ce_flags* to avoid the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 12/24] unpack-trees: avoid the_index in verify_absent() Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 13/24] pathspec.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 14/24] submodule.c: " Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 15/24] entry.c: " Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 16/24] attr: remove index from git_attr_set_direction() Nguyễn Thái Ngọc Duy
2018-08-13 17:22   ` Brandon Williams
2018-08-13 16:14 ` [PATCH 17/24] grep: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 18/24] archive.c: avoid access to the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 19/24] archive-*.c: use the right repository Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 20/24] resolve-undo.c: use the right index instead of the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 21/24] apply.c: pass struct apply_state to more functions Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 22/24] apply.c: make init_apply_state() take a struct repository Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 23/24] apply.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-08-13 16:14 ` [PATCH 24/24] blame.c: " Nguyễn Thái Ngọc Duy
2018-08-13 17:28 ` [PATCH 00/24] Kill the_index part3 Brandon Williams
2018-08-13 21:24   ` Junio C Hamano
2018-08-15 19:48     ` Stefan Beller

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=20180813171718.GB240194@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.