git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: newren@gmail.com, pclouds@gmail.com, peff@peff.net,
	jon@jonsimons.org, matvore@comcast.net,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 0/5] Refactor excludes library
Date: Tue, 03 Sep 2019 11:04:54 -0700 (PDT)	[thread overview]
Message-ID: <pull.329.git.gitgitgadget@gmail.com> (raw)

The exclude library defined in dir.h was originally written for the
.gitignore feature, but has since been used for .gitattributes and
sparse-checkout. In the later applications, these patterns are used for 
inclusion rather than exclusion, so the name is confusing. This gets
particularly bad when looking at how the sparse-checkout feature uses
is_excluded_from_list() to really mean "should be included in the working
directory".

This series performs several renames of structs and methods to generalize
the exclude library to be a "pattern matching" library. Instead of a list of
excludes, we have a list of path patterns. It is up to the consumer to
decide what to do with a match. The .gitignore logic will still treat the
patterns as a list of exclusions, the sparse-checkout logic treats the
patterns as a list of inclusions.

For this reason, some methods and structs in dir.h retain "exclude" in their
name. These are limited to things consumed only by the .gitignore feature
(as far as I can tell).

Most of these changes are mechanical find-and-replaces, with the exception
of some variable names and the last patch.

The last patch, "unpack-trees: rename 'is_excluded_from_list()'", performs a
more meaningful refactor. The method is_excluded_from_list() was only used
by sparse-checkout (inside the clear_ce_flags() methods) to see if a path
should be included in the working directory. The return value of "1 for
excluded" was confusing. Instead, use a new enum value. This required
changing several method prototypes inside unpack-trees.c.

This refactor was inspired by Elijah Newren's feedback [1] on my
sparse-checkout builtin RFC. I am working on a few other orthogonal changes
to make to the existing sparse-checkout behavior before I resubmit that RFC.

I had started working on v2.23.0, but found adjacent-diff conflicts with
md/list-objects-filter-combo [2] and js/partial-clone-sparse-blob [3]. Those
branches are independent, but the conflicts with
md/list-objects-filter-combo were more severe (and that branch seems closer
to merging) so this is based on md/list-object-filter-combo. Hopefully the
conflicts with js/partial-clone-sparse-blob are clear enough to resolve
easily.

Thanks, -Stolee

[1] 
https://public-inbox.org/git/CABPp-BFMtO=7UGVZPbqh3tthSetvz5F=W3S=RsryPSuchmZeZw@mail.gmail.com/
Re: [PATCH 8/9] sparse-checkout: use hashmaps for cone patterns

[2] https://public-inbox.org/git/cover.1558030802.git.matvore@google.com/
[RFC PATCH 0/3] implement composite filters

[3] https://public-inbox.org/git/20190828201824.1255-1-jon@jonsimons.org/
[PATCH 0/2] partial-clone: fix two issues with sparse filter handling

Derrick Stolee (5):
  treewide: rename 'struct exclude' to 'struct path_pattern'
  treewide: rename 'struct exclude_list' to 'struct pattern_list'
  treewide: rename 'EXCL_FLAG_' to 'PATTERN_FLAG_'
  treewide: rename 'exclude' methods to 'pattern'
  unpack-trees: rename 'is_excluded_from_list()'

 Documentation/RelNotes/2.7.1.txt              |   2 +-
 Documentation/RelNotes/2.8.0.txt              |   2 +-
 .../technical/api-directory-listing.txt       |   6 +-
 attr.c                                        |  10 +-
 builtin/check-ignore.c                        |  34 +--
 builtin/clean.c                               |  12 +-
 builtin/ls-files.c                            |   8 +-
 dir.c                                         | 284 +++++++++---------
 dir.h                                         |  71 +++--
 list-objects-filter.c                         |  37 +--
 unpack-trees.c                                |  67 +++--
 unpack-trees.h                                |   4 +-
 12 files changed, 285 insertions(+), 252 deletions(-)


base-commit: 90d21f9ebf6906f0ebb4fb1b20ec9536072e2916
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-329%2Fderrickstolee%2Fexclude-refactor-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-329/derrickstolee/exclude-refactor-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/329
-- 
gitgitgadget

             reply	other threads:[~2019-09-03 18:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03 18:04 Derrick Stolee via GitGitGadget [this message]
2019-09-03 18:04 ` [PATCH 1/5] treewide: rename 'struct exclude' to 'struct path_pattern' Derrick Stolee via GitGitGadget
2019-09-05  6:55   ` Jeff King
2019-09-05 21:03     ` Junio C Hamano
2019-09-03 18:04 ` [PATCH 3/5] treewide: rename 'EXCL_FLAG_' to 'PATTERN_FLAG_' Derrick Stolee via GitGitGadget
2019-09-03 18:04 ` [PATCH 2/5] treewide: rename 'struct exclude_list' to 'struct pattern_list' Derrick Stolee via GitGitGadget
2019-09-03 18:04 ` [PATCH 4/5] treewide: rename 'exclude' methods to 'pattern' Derrick Stolee via GitGitGadget
2019-09-03 18:04 ` [PATCH 5/5] unpack-trees: rename 'is_excluded_from_list()' Derrick Stolee via GitGitGadget
2019-09-04 20:25   ` Elijah Newren
2019-09-04 20:28 ` [PATCH 0/5] Refactor excludes library Elijah Newren
2019-09-06 20:34 ` Junio C Hamano

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=pull.329.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jon@jonsimons.org \
    --cc=matvore@comcast.net \
    --cc=newren@gmail.com \
    --cc=pclouds@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).