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

[PATCH] Avoid slowness when timewarping large trees.

From
Jeff King <peff@peff.net>
Date
Mar 25, 2006, 09:39 UTC
Message-ID
<20060325093957.GA27832@coredump.intra.peff.net>
In-Reply-To
<20060325093641.GA26284@coredump.intra.peff.net>

tree_timewarp was calling read, egrep, and rm in an O(N) loop where N is the number of changed files between two trees. This caused a bottleneck when seeking/switching/merging between trees with many changed files.

Signed-off-by: Jeff King <peff@peff.net>
---

This is a repost of the initial patch featuring a few cleanups suggested by Junio.

 cg-Xlib |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
5f79b37a0eb85ff4f643e70a7f2823e68e9d9ca4
diff --git a/cg-Xlib b/cg-Xlib
index 5896df7..1a9bd4f 100644
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -363,12 +363,9 @@ tree_timewarp()
 
 	# Kill gone files
 	git-diff-tree -r "$base" "$branch" |
-		while IFS=$'\t' read header file; do
-			# match ":100755 000000 14d43b1abf... 000000000... D"
-			if echo "$header" | egrep "^:([^ ][^ ]* ){4}D" >/dev/null; then
-				rm -- "$file"
-			fi
-		done
+		# match ":100755 000000 14d43b1abf... 000000000... D"
+		sed -ne 's/^:[^\t]* D\t//p' |
+		xargs rm -f --
 	git-checkout-index -u -f -a
 
 	# FIXME: Can produce bogus "contains only garbage" messages.
-- 
1.2.4
Previous: Jeff KingNext: Petr Baudis
Message 8 of 10 in “cogito: Avoid slowness when timewarping large trees.”
  1. cogito: Avoid slowness when timewarping large trees.Jeff King, Mar 24, 2006
  2. Junio C HamanoMar 24, 2006
  3. Jeff KingMar 24, 2006
  4. Junio C HamanoMar 24, 2006
  5. Jeff KingMar 24, 2006
  6. Shawn PearceMar 24, 2006
  7. Jeff KingMar 25, 2006
  8. Avoid slowness when timewarping large trees.Jeff King, Mar 25, 2006
  9. Petr BaudisMar 26, 2006
  10. Junio C HamanoMar 25, 2006

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.