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

[PATCH v2] oneway_merge(): only lstat() when told to update worktree

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Dec 20, 2012, 21:03 UTC
Message-ID
<1356037416-23527-1-git-send-email-martinvonz@gmail.com>
In-Reply-To
<7vk3sc4hle.fsf@alter.siamese.dyndns.org>

Although the subject line of 613f027 (read-tree -u one-way merge fix to check out locally modified paths., 2006-05-15) mentions "read-tree -u", it did not seem to check whether -u was in effect. Not checking whether -u is in effect makes e.g. "read-tree --reset" lstat() the worktree, even though the worktree stat should not matter for that operation.

This speeds up e.g. "git reset" a little on the linux-2.6 repo (best of five, warm cache):

        Before      After
real    0m0.288s    0m0.233s
user    0m0.190s    0m0.150s
sys     0m0.090s    0m0.080s
Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com>
---
 unpack-trees.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 6d96366..61acc5e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1834,7 +1834,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
 
 	if (old && same(old, a)) {
 		int update = 0;
-		if (o->reset && !ce_uptodate(old) && !ce_skip_worktree(old)) {
+		if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old)) {
 			struct stat st;
 			if (lstat(old->name, &st) ||
 			    ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
-- 
1.8.0.1.240.ge8a1f5a
Previous: Junio C Hamano
Message 3 of 3 in “oneway_merge(): only lstat() when told to update worktree”
  1. oneway_merge(): only lstat() when told to update worktreeMartin von Zweigbergk, Dec 20, 2012
  2. Junio C HamanoDec 20, 2012
  3. oneway_merge(): only lstat() when told to update worktreeMartin von Zweigbergk, Dec 20, 2012

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.