From: Josip Sokcevic <sokcevic@google.com>
To: jonathantanmy@google.com
Cc: git@vger.kernel.org, git@jeffhostetler.com,
Josip Sokcevic <sokcevic@google.com>
Subject: [PATCH] [diff-lib] Fix check_removed when fsmonitor is on
Date: Tue, 5 Sep 2023 23:02:42 -0700 [thread overview]
Message-ID: <20230906060241.944886-2-sokcevic@google.com> (raw)
In-Reply-To: <20230829005606.136615-1-jonathantanmy@google.com>
git-diff-index may return incorrect deleted entries when fsmonitor is used in a
repository with git submodules. This can be observed on Mac machines, but it
can affect all other supported platforms too.
If fsmonitor is used, `stat *st` may not be initialized. Since `lstat` calls
aren't not desired when fsmonitor is on, skip the entire gitlink check using
the same condition used to initialize `stat *st`.
---
This patch is using jonathantanmy@ test case, which now passes. It's
possible there are similar edge cases with fsmonitor, so I'll do more
extensive e2e testing tomorrow.
diff-lib.c | 2 +-
t/t7527-builtin-fsmonitor.sh | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/diff-lib.c b/diff-lib.c
index d8aa777a73..c67aa5ff89 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -46,7 +46,7 @@ static int check_removed(const struct index_state *istate, const struct cache_en
}
if (has_symlink_leading_path(ce->name, ce_namelen(ce)))
return 1;
- if (S_ISDIR(st->st_mode)) {
+ if (!(ce->ce_flags & CE_FSMONITOR_VALID) && S_ISDIR(st->st_mode)) {
struct object_id sub;
/*
diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh
index 0c241d6c14..894a80fbe8 100755
--- a/t/t7527-builtin-fsmonitor.sh
+++ b/t/t7527-builtin-fsmonitor.sh
@@ -824,6 +824,10 @@ test_expect_success 'submodule always visited' '
create_super super &&
create_sub sub &&
+ git -C super --no-optional-locks diff-index --name-status HEAD >actual.with &&
+ git -C super --no-optional-locks -c core.fsmonitor=false \
+ diff-index --name-status HEAD >actual.without &&
+ test_cmp actual.with actual.without &&
git -C super submodule add ../sub ./dir_1/dir_2/sub &&
git -C super commit -m "add sub" &&
@@ -837,6 +841,8 @@ test_expect_success 'submodule always visited' '
# some dirt in the submodule and confirm matching output.
# Completely clean status.
+ echo Now running for clean status &&
+
my_match_and_clean &&
# .M S..U
--
2.42.0.283.g2d96d420d3-goog
next prev parent reply other threads:[~2023-09-06 6:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 0:56 Strange diff-index with fsmonitor, submodules Jonathan Tan
2023-08-29 1:20 ` Junio C Hamano
2023-08-29 12:45 ` Jeff Hostetler
2023-08-29 16:57 ` Jeff Hostetler
2023-08-29 17:01 ` Jonathan Tan
2023-09-06 6:02 ` Josip Sokcevic [this message]
2023-09-06 20:37 ` [PATCH] [diff-lib] Fix check_removed when fsmonitor is on Jonathan Tan
2023-09-07 17:01 ` [PATCH v2] diff-lib: " Josip Sokcevic
2023-09-07 17:22 ` Jonathan Tan
2023-09-07 18:07 ` Junio C Hamano
2023-09-07 23:08 ` Josip Sokcevic
2023-09-08 15:00 ` Junio C Hamano
2023-09-11 17:09 ` [PATCH v3] " Josip Sokcevic
2023-09-11 22:53 ` Junio C Hamano
2023-09-12 3:03 ` Josip Sokcevic
2023-09-12 17:07 ` Junio C Hamano
2023-09-14 22:39 ` Josip Sokcevic
2023-09-18 16:35 ` 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=20230906060241.944886-2-sokcevic@google.com \
--to=sokcevic@google.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.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.