diff mbox series

[v3,11/14] fsmonitor: return invalided cache-entry count on non-directory event

Message ID 53f73c1515d0f64bf13f0b30e9039dedbf441f2c.1708983566.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 9e34e562805986b1ed0d1518a5822b9ec495960b
Headers show
Series FSMonitor edge cases on case-insensitive file systems | expand

Commit Message

Jeff Hostetler Feb. 26, 2024, 9:39 p.m. UTC
From: Jeff Hostetler <jeffhostetler@github.com>

Teach the refresh callback helper function for unqualified FSEvents
(pathnames without a trailing slash) to return the number of
cache-entries that were invalided in response to the event.

This will be used in a later commit to help determine if the observed
pathname was (possibly) case-incorrect when (on a case-insensitive
file system).

Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
---
 fsmonitor.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Patrick Steinhardt March 6, 2024, 12:58 p.m. UTC | #1
Nit, not worth a reroll: the subject says "invalided" instead of
"invalidated".

Patrick

On Mon, Feb 26, 2024 at 09:39:22PM +0000, Jeff Hostetler via GitGitGadget wrote:
> From: Jeff Hostetler <jeffhostetler@github.com>
> 
> Teach the refresh callback helper function for unqualified FSEvents
> (pathnames without a trailing slash) to return the number of
> cache-entries that were invalided in response to the event.
> 
> This will be used in a later commit to help determine if the observed
> pathname was (possibly) case-incorrect when (on a case-insensitive
> file system).
> 
> Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
> ---
>  fsmonitor.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fsmonitor.c b/fsmonitor.c
> index a51c17cda70..c16ed5d8758 100644
> --- a/fsmonitor.c
> +++ b/fsmonitor.c
> @@ -196,8 +196,10 @@ static size_t handle_path_with_trailing_slash(
>   * do not know it is case-correct or -incorrect.
>   *
>   * Assume it is case-correct and try an exact match.
> + *
> + * Return the number of cache-entries that we invalidated.
>   */
> -static void handle_path_without_trailing_slash(
> +static size_t handle_path_without_trailing_slash(
>  	struct index_state *istate, const char *name, int pos)
>  {
>  	/*
> @@ -218,7 +220,9 @@ static void handle_path_without_trailing_slash(
>  		 * at that directory. (That is, assume no D/F conflicts.)
>  		 */
>  		istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID;
> +		return 1;
>  	} else {
> +		size_t nr_in_cone;
>  		struct strbuf work_path = STRBUF_INIT;
>  
>  		/*
> @@ -232,8 +236,10 @@ static void handle_path_without_trailing_slash(
>  		strbuf_add(&work_path, name, strlen(name));
>  		strbuf_addch(&work_path, '/');
>  		pos = index_name_pos(istate, work_path.buf, work_path.len);
> -		handle_path_with_trailing_slash(istate, work_path.buf, pos);
> +		nr_in_cone = handle_path_with_trailing_slash(
> +			istate, work_path.buf, pos);
>  		strbuf_release(&work_path);
> +		return nr_in_cone;
>  	}
>  }
>  
> -- 
> gitgitgadget
>
diff mbox series

Patch

diff --git a/fsmonitor.c b/fsmonitor.c
index a51c17cda70..c16ed5d8758 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -196,8 +196,10 @@  static size_t handle_path_with_trailing_slash(
  * do not know it is case-correct or -incorrect.
  *
  * Assume it is case-correct and try an exact match.
+ *
+ * Return the number of cache-entries that we invalidated.
  */
-static void handle_path_without_trailing_slash(
+static size_t handle_path_without_trailing_slash(
 	struct index_state *istate, const char *name, int pos)
 {
 	/*
@@ -218,7 +220,9 @@  static void handle_path_without_trailing_slash(
 		 * at that directory. (That is, assume no D/F conflicts.)
 		 */
 		istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID;
+		return 1;
 	} else {
+		size_t nr_in_cone;
 		struct strbuf work_path = STRBUF_INIT;
 
 		/*
@@ -232,8 +236,10 @@  static void handle_path_without_trailing_slash(
 		strbuf_add(&work_path, name, strlen(name));
 		strbuf_addch(&work_path, '/');
 		pos = index_name_pos(istate, work_path.buf, work_path.len);
-		handle_path_with_trailing_slash(istate, work_path.buf, pos);
+		nr_in_cone = handle_path_with_trailing_slash(
+			istate, work_path.buf, pos);
 		strbuf_release(&work_path);
+		return nr_in_cone;
 	}
 }