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

Re: [PATCH v2 00/19] Index-v5

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Jul 15, 2013, 09:30 UTC
Message-ID
<87ehb0cgqt.fsf@gmail.com>
In-Reply-To
<CACsJy8AhmYBjzqPtF3f9Gk8hq2bk8-PtFCto9_4AkRePomvhAQ@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 9 quoted lines
> On Sat, Jul 13, 2013 at 12:26 AM, Thomas Gummerer <t.gummerer@gmail.com> wrote:
>>  t/perf/p0003-index.sh                            |   59 +
>>  t/t2104-update-index-skip-worktree.sh            |    1 +
>
> For such a big code addition, the test part seems modest. Speaking
> from my experience, I rarely run perf tests and "make test" does not
> activate v5 code at all. A few more tests would be nice. The good news
> is I changed default index version to 5 and ran "make test", all
> passed.

I was using the test suite with index version 5 as default index version for testing of the new index file format. I think that's the best way to test the index, as it covers all aspects. Maybe we should add a test that covers the basic functionality, just to make sure nothing obvious is broken when running the test suite with index-v2? Something like this maybe:

--->8---
>From c476b521c94f1a9b0b4fcfe92d63321442d79c9a Mon Sep 17 00:00:00 2001
From: Thomas Gummerer <t.gummerer@gmail.com>
Date: Mon, 15 Jul 2013 11:21:06 +0200
Subject: [PATCH] t1600: add basic test for index-v5

Add a test that checks the index-v5 file format when running the test-suite with index-v2 as default index format. When making changes to the index, the test suite still should be run with both index v2 and index v5 as default index format, for better coverage of all aspects of the index.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 t/t1600-index-v5.sh | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100755 t/t1600-index-v5.sh
diff --git a/t/t1600-index-v5.sh b/t/t1600-index-v5.sh
new file mode 100755
index 0000000..528c17e
--- /dev/null
+++ b/t/t1600-index-v5.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# Copyright (c) 2013 Thomas Gummerer
+
+test_description='Test basic functionaltiy of index-v5.
+
+This test just covers the basics, to make sure normal runs of the test
+suite cover this version of the index file format too.  For better
+testing of the index-v5 format, the default index version should be
+changed to 5 and the test suite should be re-run'
+
+. ./test-lib.sh
+
+check_resolve_undo () {
+	msg=$1
+	shift
+	while case $# in
+	0)	break ;;
+	1|2|3)	die "Bug in check-resolve-undo test" ;;
+	esac
+	do
+		path=$1
+		shift
+		for stage in 1 2 3
+		do
+			sha1=$1
+			shift
+			case "$sha1" in
+			'') continue ;;
+			esac
+			sha1=$(git rev-parse --verify "$sha1")
+			printf "100644 %s %s\t%s\n" $sha1 $stage $path
+		done
+	done >"$msg.expect" &&
+	git ls-files --resolve-undo >"$msg.actual" &&
+	test_cmp "$msg.expect" "$msg.actual"
+}
+
+prime_resolve_undo () {
+	git reset --hard &&
+	git checkout second^0 &&
+	test_tick &&
+	test_must_fail git merge third^0 &&
+	echo merge does not leave anything &&
+	check_resolve_undo empty &&
+	echo different >fi/le &&
+	git add fi/le &&
+	echo resolving records &&
+	check_resolve_undo recorded fi/le initial:fi/le second:fi/le third:fi/le
+}
+
+test_expect_success 'setup' '
+	git update-index --index-version=5 &&
+	echo file1 >file1 &&
+	echo file2 >file2 &&
+	mkdir -p top/sub &&
+	echo x >top/x &&
+	echo xy >top/xy &&
+	echo y >top/y &&
+	echo yx >top/yx &&
+	echo sub1 >top/sub/sub1 &&
+	git add . &&
+	git commit -m "initial import"
+'
+
+test_expect_success 'ls-files shows all files' '
+	cat >expected <<-EOF &&
+	100644 e2129701f1a4d54dc44f03c93bca0a2aec7c5449 0	file1
+	100644 6c493ff740f9380390d5c9ddef4af18697ac9375 0	file2
+	100644 48df0cb83fee5d667537343f60a6057a63dd3c9b 0	top/sub/sub1
+	100644 587be6b4c3f93f93c489c0111bba5596147a26cb 0	top/x
+	100644 5aad9376af82d7b98a34f95fb0f298a162f52656 0	top/xy
+	100644 975fbec8256d3e8a3797e7a3611380f27c49f4ac 0	top/y
+	100644 ba1575927fa5b1f4bce72ad0c349566f1b02508e 0	top/yx
+	EOF
+	git ls-files --stage >actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'ls-files with pathspec in subdir' '
+	cd top/sub &&
+	cat >expected <<-EOF &&
+	../x
+	../xy
+	EOF
+	git ls-files --error-unmatch ../x* >actual &&
+	test_cmp expected actual &&
+	cd ../..
+'
+
+test_expect_success 'read-tree HEAD establishes cache-tree' '
+	git read-tree HEAD &&
+	cat >expected <<-EOF &&
+	84e73410ea7864ccada24d897462e8ce1e1b872b  (7 entries, 1 subtrees)
+	602482536bd3852e8ac2977ed1a9913a8c244aa0 top/ (5 entries, 1 subtrees)
+	20bb0109200f37a7e19283b4abc4a672be3f0adb top/sub/ (1 entries, 0 subtrees)
+	EOF
+	test-dump-cache-tree >actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'setup resolve-undo' '
+	mkdir fi &&
+	printf "a\0a" >binary &&
+	git add binary &&
+	test_commit initial fi/le first &&
+	git branch side &&
+	git branch another &&
+	printf "a\0b" >binary &&
+	git add binary &&
+	test_commit second fi/le second &&
+	git checkout side &&
+	test_commit third fi/le third &&
+	git branch add-add &&
+	git checkout another &&
+	test_commit fourth fi/le fourth &&
+	git checkout add-add &&
+	test_commit fifth add-differently &&
+	git checkout master
+'
+
+test_expect_success 'add records switch clears' '
+	prime_resolve_undo &&
+	test_tick &&
+	git commit -m merged &&
+	echo committing keeps &&
+	check_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&
+	git checkout second^0 &&
+	echo switching clears &&
+	check_resolve_undo cleared
+'
+
+test_done
--
1.8.3.453.g1dfc63d
Previous: Duy NguyenNext: Duy Nguyen
Message 44 of 51 in “Index-v5”
  1. 00/19 Index-v5Thomas Gummerer, Jul 12, 2013
  2. 01/19 t2104: Don't fail for index versions other than [23]Thomas Gummerer, Jul 12, 2013
  3. 02/19 read-cache: split index file version specific functionalityThomas Gummerer, Jul 12, 2013
  4. 03/19 read-cache: move index v2 specific functions to their own fileThomas Gummerer, Jul 12, 2013
  5. Duy NguyenJul 14, 2013
  6. Thomas GummererJul 19, 2013
  7. 04/19 read-cache: Re-read index if index file changedThomas Gummerer, Jul 12, 2013
  8. 05/19 Add documentation for the index apiThomas Gummerer, Jul 12, 2013
  9. 06/19 read-cache: add index reading apiThomas Gummerer, Jul 12, 2013
  10. Duy NguyenJul 14, 2013
  11. 07/19 make sure partially read index is not changedThomas Gummerer, Jul 12, 2013
  12. Duy NguyenJul 14, 2013
  13. Thomas GummererJul 17, 2013
  14. 08/19 grep.c: Use index apiThomas Gummerer, Jul 12, 2013
  15. Duy NguyenJul 14, 2013
  16. Thomas GummererJul 15, 2013
  17. 09/19 ls-files.c: use index apiThomas Gummerer, Jul 12, 2013
  18. Duy NguyenJul 14, 2013
  19. Thomas GummererJul 17, 2013
  20. 10/19 documentation: add documentation of the index-v5 file formatThomas Gummerer, Jul 12, 2013
  21. Duy NguyenJul 14, 2013
  22. Thomas GummererJul 17, 2013
  23. Duy NguyenAug 4, 2013
  24. Thomas GummererAug 4, 2013
  25. 11/19 read-cache: make in-memory format aware of stat_crcThomas Gummerer, Jul 12, 2013
  26. 12/19 read-cache: read index-v5Thomas Gummerer, Jul 12, 2013
  27. Duy NguyenJul 14, 2013
  28. Thomas GummererAug 7, 2013
  29. Duy NguyenJul 15, 2013
  30. Thomas GummererJul 17, 2013
  31. Duy NguyenAug 8, 2013
  32. Thomas GummererAug 8, 2013
  33. Thomas GummererAug 9, 2013
  34. Thomas GummererAug 7, 2013
  35. Duy NguyenAug 8, 2013
  36. 13/19 read-cache: read resolve-undo dataThomas Gummerer, Jul 12, 2013
  37. 14/19 read-cache: read cache-tree in index-v5Thomas Gummerer, Jul 12, 2013
  38. 15/19 read-cache: write index-v5Thomas Gummerer, Jul 12, 2013
  39. 16/19 read-cache: write index-v5 cache-tree dataThomas Gummerer, Jul 12, 2013
  40. 17/19 read-cache: write resolve-undo data for index-v5Thomas Gummerer, Jul 12, 2013
  41. 18/19 update-index.c: rewrite index when index-version is givenThomas Gummerer, Jul 12, 2013
  42. 19/19 p0003-index.sh: add perf test for the index formatsThomas Gummerer, Jul 12, 2013
  43. Duy NguyenJul 14, 2013
  44. Thomas GummererJul 15, 2013
  45. Duy NguyenJul 15, 2013
  46. Thomas GummererJul 17, 2013
  47. Junio C HamanoJul 17, 2013
  48. Thomas GummererJul 19, 2013
  49. Junio C HamanoJul 19, 2013
  50. Ramsay JonesJul 16, 2013
  51. Thomas GummererJul 17, 2013

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.