Skip to content

Commit 671eaaa

Browse files
committed
Merge branch 'js/diff-cached-fsmonitor-fix'
"git diff --cached" codepath did not fill the necessary stat information for a file when fsmonitor knows it is clean and ended up behaving as if it is not clean, which has been corrected. * js/diff-cached-fsmonitor-fix: diff-lib: fix check_removed when fsmonitor is on
2 parents bd49a29 + 6a044a2 commit 671eaaa

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

diff-lib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
* exists for ce that is a submodule -- it is a submodule that is not
3737
* checked out). Return negative for an error.
3838
*/
39-
static int check_removed(const struct index_state *istate, const struct cache_entry *ce, struct stat *st)
39+
static int check_removed(const struct cache_entry *ce, struct stat *st)
4040
{
41-
assert(is_fsmonitor_refreshed(istate));
42-
if (!(ce->ce_flags & CE_FSMONITOR_VALID) && lstat(ce->name, st) < 0) {
41+
if (lstat(ce->name, st) < 0) {
4342
if (!is_missing_file_error(errno))
4443
return -1;
4544
return 1;
4645
}
46+
4747
if (has_symlink_leading_path(ce->name, ce_namelen(ce)))
4848
return 1;
4949
if (S_ISDIR(st->st_mode)) {
@@ -149,7 +149,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
149149
memset(&(dpath->parent[0]), 0,
150150
sizeof(struct combine_diff_parent)*5);
151151

152-
changed = check_removed(istate, ce, &st);
152+
changed = check_removed(ce, &st);
153153
if (!changed)
154154
wt_mode = ce_mode_from_stat(ce, st.st_mode);
155155
else {
@@ -229,7 +229,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
229229
} else {
230230
struct stat st;
231231

232-
changed = check_removed(istate, ce, &st);
232+
changed = check_removed(ce, &st);
233233
if (changed) {
234234
if (changed < 0) {
235235
perror(ce->name);
@@ -303,7 +303,7 @@ static int get_stat_data(const struct index_state *istate,
303303
if (!cached && !ce_uptodate(ce)) {
304304
int changed;
305305
struct stat st;
306-
changed = check_removed(istate, ce, &st);
306+
changed = check_removed(ce, &st);
307307
if (changed < 0)
308308
return -1;
309309
else if (changed) {

t/t7527-builtin-fsmonitor.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ my_match_and_clean () {
809809
status --porcelain=v2 >actual.without &&
810810
test_cmp actual.with actual.without &&
811811

812+
git -C super --no-optional-locks diff-index --name-status HEAD >actual.with &&
813+
git -C super --no-optional-locks -c core.fsmonitor=false \
814+
diff-index --name-status HEAD >actual.without &&
815+
test_cmp actual.with actual.without &&
816+
812817
git -C super/dir_1/dir_2/sub reset --hard &&
813818
git -C super/dir_1/dir_2/sub clean -d -f
814819
}

0 commit comments

Comments
 (0)