From: Ben Peart <Ben.Peart@microsoft.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Cc: "pclouds@gmail.com" <pclouds@gmail.com>,
"alexmv@dropbox.com" <alexmv@dropbox.com>,
"blees@dcon.de" <blees@dcon.de>,
"gitster@pobox.com" <gitster@pobox.com>,
"bmwill@google.com" <bmwill@google.com>,
"avarab@gmail.com" <avarab@gmail.com>,
"johannes.schindelin@gmx.de" <johannes.schindelin@gmx.de>,
"martin.agren@gmail.com" <martin.agren@gmail.com>,
Ben Peart <Ben.Peart@microsoft.com>
Subject: [PATCH v2 0/2] fsexcludes: Add programmatic way to exclude files
Date: Wed, 11 Apr 2018 20:01:24 +0000 [thread overview]
Message-ID: <20180411200007.8612-1-benpeart@microsoft.com> (raw)
In-Reply-To: <20180410210408.13788-1-benpeart@microsoft.com>
Updated to incorporate feedback from V1.
I'd really like a close review of the changes in dir.c where I added the calls
to fsexcludes_is_excluded_from(). While they work and pass all the git tests
as well as our internal functional tests, I'd like to be sure I haven't missed
anything.
Base Ref: master
Web-Diff: https://github.com/benpeart/git/commit/08442c209d
Checkout: git fetch https://github.com/benpeart/git fsexcludes-v2 && git checkout 08442c209d
### Interdiff (v1..v2):
diff --git a/fsexcludes.c b/fsexcludes.c
index 07bfe376a0..0ef57f107b 100644
--- a/fsexcludes.c
+++ b/fsexcludes.c
@@ -33,7 +33,6 @@ static int check_fsexcludes_hashmap(struct hashmap *map, const char *pattern, in
char *slash;
/* Check straight mapping */
- strbuf_reset(&sb);
strbuf_add(&sb, pattern, patternlen);
fse.pattern = sb.buf;
fse.patternlen = sb.len;
@@ -155,7 +154,6 @@ static int check_directory_hashmap(struct hashmap *map, const char *pathname, in
struct fsexcludes fse;
/* Check for directory */
- strbuf_reset(&sb);
strbuf_add(&sb, pathname, pathlen);
strbuf_addch(&sb, '/');
fse.pattern = sb.buf;
@@ -198,13 +196,16 @@ int fsexcludes_is_excluded_from(struct index_state *istate,
return -1;
}
-void fsexcludes_init(struct strbuf *sb) {
+void fsexcludes_init(struct strbuf *sb)
+{
fsexcludes_initialized = 1;
fsexcludes_data = *sb;
+ strbuf_detach(sb, NULL);
}
-void fsexcludes_free() {
+void fsexcludes_free(void) {
strbuf_release(&fsexcludes_data);
hashmap_free(&fsexcludes_hashmap, 1);
hashmap_free(&parent_directory_hashmap, 1);
+ fsexcludes_initialized = 0;
}
diff --git a/fsexcludes.h b/fsexcludes.h
index 1c4101343c..10246daa02 100644
--- a/fsexcludes.h
+++ b/fsexcludes.h
@@ -6,16 +6,18 @@
* where git will scan for untracked files. This is used to speed up the
* scan by avoiding scanning parts of the work directory that do not have
* any new files.
- *
*/
/*
* sb should contain a NUL separated list of path names of the files
* and/or directories that should be checked. Any path not listed will
* be excluded from the scan.
+ *
+ * NOTE: fsexcludes_init() will take ownership of the storage passed in
+ * sb and will reset sb to `STRBUF_INIT`
*/
void fsexcludes_init(struct strbuf *sb);
-void fsexcludes_free();
+void fsexcludes_free(void);
/*
* Return 1 for exclude, 0 for include and -1 for undecided.
### Patches
Ben Peart (2):
fsexcludes: add a programmatic way to exclude files from git's working
directory traversal logic
fsmonitor: switch to use new fsexcludes logic and remove unused
untracked cache based logic
Makefile | 1 +
dir.c | 33 ++++--
dir.h | 2 -
fsexcludes.c | 211 ++++++++++++++++++++++++++++++++++++
fsexcludes.h | 29 +++++
fsmonitor.c | 21 +---
fsmonitor.h | 10 +-
t/t7519-status-fsmonitor.sh | 14 +--
8 files changed, 273 insertions(+), 48 deletions(-)
create mode 100644 fsexcludes.c
create mode 100644 fsexcludes.h
base-commit: 0b0cc9f86731f894cff8dd25299a9b38c254569e
--
2.17.0.windows.1
next prev parent reply other threads:[~2018-04-11 20:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-10 21:04 [PATCH v1 0/2] fsexcludes: Add programmatic way to exclude files Ben Peart
2018-04-10 21:04 ` [PATCH v1 1/2] fsexcludes: add a programmatic way to exclude files from git's working directory traversal logic Ben Peart
2018-04-10 22:09 ` Martin Ågren
2018-04-11 19:56 ` Ben Peart
2018-04-11 6:58 ` Junio C Hamano
2018-04-10 21:04 ` [PATCH v1 2/2] fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logic Ben Peart
2018-04-11 20:01 ` Ben Peart [this message]
2018-04-11 20:01 ` [PATCH v2 1/2] fsexcludes: add a programmatic way to exclude files from git's working directory traversal logic Ben Peart
2018-04-11 23:52 ` Junio C Hamano
2018-04-13 11:53 ` Ben Peart
2018-04-11 20:01 ` [PATCH v2 2/2] fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logic Ben Peart
2018-04-13 12:22 ` [PATCH v3 0/2] fsexcludes: Add programmatic way to exclude files Ben Peart
2018-04-13 12:22 ` [PATCH v3 1/2] fsexcludes: add a programmatic way to exclude files from git's working directory traversal logic Ben Peart
2018-04-13 12:22 ` [PATCH v3 2/2] fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logic Ben Peart
2018-04-18 15:31 ` [PATCH v3 0/2] fsexcludes: Add programmatic way to exclude files Ben Peart
2018-04-18 21:25 ` Junio C Hamano
2018-04-14 15:59 ` [PATCH v1 " Duy Nguyen
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=20180411200007.8612-1-benpeart@microsoft.com \
--to=ben.peart@microsoft.com \
--cc=alexmv@dropbox.com \
--cc=avarab@gmail.com \
--cc=blees@dcon.de \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=martin.agren@gmail.com \
--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.
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).