git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/3] fsmonitor: skip lstat deletion check during git diff-index

From
Nipunn Koorapati via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 17, 2021, 21:22 UTC
Message-ID
<75a3c46c405549d1f5127097729c556a7e297587.1616016143.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.903.v2.git.1616016143.gitgitgadget@gmail.com>
From: Nipunn Koorapati <nipunn@dropbox.com>

Teach git to honor fsmonitor rather than issuing an lstat when checking for dirty local deletes. Eliminates O(files) lstats during `git diff HEAD`

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
---
 diff-lib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/diff-lib.c b/diff-lib.c
index b73cc1859a49..3fb538ad18e9 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -30,7 +30,7 @@
  */
 static int check_removed(const struct cache_entry *ce, struct stat *st)
 {
-	if (lstat(ce->name, st) < 0) {
+	if (!(ce->ce_flags & CE_FSMONITOR_VALID) && lstat(ce->name, st) < 0) {
 		if (!is_missing_file_error(errno))
 			return -1;
 		return 1;
@@ -574,6 +574,7 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
 	struct object_id oid;
 	const char *name;
 	char merge_base_hex[GIT_MAX_HEXSZ + 1];
+	struct index_state *istate = revs->diffopt.repo->index;
 
 	if (revs->pending.nr != 1)
 		BUG("run_diff_index must be passed exactly one tree");
@@ -581,6 +582,8 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
 	trace_performance_enter();
 	ent = revs->pending.objects;
 
+	refresh_fsmonitor(istate);
+
 	if (merge_base) {
 		diff_get_merge_base(revs, &oid);
 		name = oid_to_hex_r(merge_base_hex, &oid);
-- 
gitgitgadget
Previous: Nipunn Koorapati via GitGitGadgetNext: Junio C Hamano
Message 9 of 15 in “teach git to respect fsmonitor in diff-index”
  1. 0/3 teach git to respect fsmonitor in diff-indexNipunn Koorapati via GitGitGadget, Mar 14, 2021
  2. 1/3 fsmonitor: skip lstat deletion check during git diff-indexNipunn Koorapati via GitGitGadget, Mar 14, 2021
  3. 3/3 fsmonitor: add perf test for git diff HEADNipunn Koorapati via GitGitGadget, Mar 14, 2021
  4. 2/3 fsmonitor: add assertion that fsmonitor is valid to check_removedNipunn Koorapati via GitGitGadget, Mar 14, 2021
  5. Eric SunshineMar 14, 2021
  6. Nipunn KoorapatiMar 15, 2021
  7. Eric SunshineMar 15, 2021
  8. 0/3 teach git to respect fsmonitor in diff-indexNipunn Koorapati via GitGitGadget, Mar 17, 2021
  9. 1/3 fsmonitor: skip lstat deletion check during git diff-indexNipunn Koorapati via GitGitGadget, Mar 17, 2021
  10. Junio C HamanoMar 18, 2021
  11. Nipunn KoorapatiMar 18, 2021
  12. 3/3 fsmonitor: add perf test for git diff HEADNipunn Koorapati via GitGitGadget, Mar 17, 2021
  13. 2/3 fsmonitor: add assertion that fsmonitor is valid to check_removedNipunn Koorapati via GitGitGadget, Mar 17, 2021
  14. Junio C HamanoMar 18, 2021
  15. Nipunn KoorapatiMar 18, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.