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

[PATCH v2 1/2] fast-import: add a test for tree delta base corruption

From
Dmitry Ivankov <divanorama@gmail.com>
Date
Aug 14, 2011, 18:32 UTC
Message-ID
<1313346744-30340-2-git-send-email-divanorama@gmail.com>
In-Reply-To
<1313145170-24471-1-git-send-email-divanorama@gmail.com>

fast-import is able to write imported tree objects in delta format. It holds a tree structure in memory where each tree entry may have a delta base sha1 assigned. When delta base data is needed it is reconstructed from this in-memory structure. Though sometimes the delta base data doesn't match the delta base sha1 so wrong or even corrupt pack is produced.

Add a small test that produces a corrupt pack. It uses just tree copy and file modification commands aside from the very basic commit and blob commands.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
 t/t9300-fast-import.sh |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index f256475..e2b94b5 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -734,6 +734,47 @@ test_expect_success \
 	 git diff-tree --abbrev --raw L^ L >output &&
 	 test_cmp expect output'
 
+cat >input <<INPUT_END
+blob
+mark :1
+data <<EOF
+the data
+EOF
+
+commit refs/heads/L2
+committer C O Mitter <committer@example.com> 1112912473 -0700
+data <<COMMIT
+init L2
+COMMIT
+M 644 :1 a/b/c
+M 644 :1 a/b/d
+M 644 :1 a/e/f
+
+commit refs/heads/L2
+committer C O Mitter <committer@example.com> 1112912473 -0700
+data <<COMMIT
+update L2
+COMMIT
+C a g
+C a/e g/b
+M 644 :1 g/b/h
+INPUT_END
+
+cat <<EOF >expect
+g/b/f
+g/b/h
+EOF
+
+test_expect_failure \
+    'L: nested tree copy does not corrupt deltas' \
+	'git fast-import <input &&
+	git ls-tree L2 g/b/ >tmp &&
+	cat tmp | cut -f 2 >actual &&
+	test_cmp expect actual &&
+	git fsck `git rev-parse L2`'
+
+git update-ref -d refs/heads/L2
+
 ###
 ### series M
 ###
-- 
1.7.3.4
Previous: Dmitry IvankovNext: Dmitry Ivankov
Message 7 of 14 in “fix data corruption in fast-import”
  1. 0/3 fix data corruption in fast-importDmitry Ivankov, Aug 12, 2011
  2. 1/3 fast-import: extract object preparation functionDmitry Ivankov, Aug 12, 2011
  3. 2/3 fast-import: add a check for tree delta base sha1Dmitry Ivankov, Aug 12, 2011
  4. Jonathan NiederAug 13, 2011
  5. 3/3 fast-import: prevent producing bad deltaDmitry Ivankov, Aug 12, 2011
  6. 0/2 fix data corruption in fast-importDmitry Ivankov, Aug 14, 2011
  7. 1/2 fast-import: add a test for tree delta base corruptionDmitry Ivankov, Aug 14, 2011
  8. 2/2 fast-import: prevent producing bad deltaDmitry Ivankov, Aug 14, 2011
  9. fast-import: do not write bad delta for replaced subtreesJonathan Nieder, Aug 20, 2011
  10. Andreas SchwabAug 20, 2011
  11. Jonathan NiederAug 20, 2011
  12. fast-import: do not write bad delta for replaced subtreesDmitry Ivankov, Aug 20, 2011
  13. Jonathan NiederAug 20, 2011
  14. Dmitry IvankovAug 20, 2011

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.