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

[PATCH 6/6] fast-import: use the diff_delta() max_delta_size argument

From
Nicolas Pitre <nico@fluxnic.net>
Date
Feb 17, 2010, 19:05 UTC
Message-ID
<1266433556-1987-7-git-send-email-nico@fluxnic.net>
In-Reply-To
<1266433556-1987-1-git-send-email-nico@fluxnic.net>

This let diff_delta() abort early if it is going to bust the given size limit. Also, only objects larger than 20 bytes are considered as objects smaller than that are most certainly going to produce larger deltas than the original object due to the additional headers.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
---
 fast-import.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7fc9862..74f08bd 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1041,14 +1041,10 @@ static int store_object(
 		return 1;
 	}
 
-	if (last && last->data.buf && last->depth < max_depth) {
+	if (last && last->data.buf && last->depth < max_depth && dat->len > 20) {
 		delta = diff_delta(last->data.buf, last->data.len,
 			dat->buf, dat->len,
-			&deltalen, 0);
-		if (delta && deltalen >= dat->len) {
-			free(delta);
-			delta = NULL;
-		}
+			&deltalen, dat->len - 20);
 	} else
 		delta = NULL;
 
-- 
1.7.0.23.gf5ef4
Previous: Nicolas PitreNext: Shawn O. Pearce
Message 7 of 9 in “fast-import updates”
  1. 0/6 fast-import updatesNicolas Pitre, Feb 17, 2010
  2. 1/6 fast-import: start using struct pack_idx_entryNicolas Pitre, Feb 17, 2010
  3. 2/6 fast-import: use sha1write() for pack dataNicolas Pitre, Feb 17, 2010
  4. 3/6 fast-import: use write_idx_file() instead of custom codeNicolas Pitre, Feb 17, 2010
  5. 4/6 fast-import: make default pack size unlimitedNicolas Pitre, Feb 17, 2010
  6. 5/6 fast-import: honor pack.indexversion and pack.packsizelimit config varsNicolas Pitre, Feb 17, 2010
  7. 6/6 fast-import: use the diff_delta() max_delta_size argumentNicolas Pitre, Feb 17, 2010
  8. Shawn O. PearceFeb 17, 2010
  9. Junio C HamanoFeb 17, 2010

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.