test-lib: allow setting the index format version

Allow adding a TEST_GIT_INDEX_VERSION variable to config.mak to set the index version with which the test suite should be run. If it isn't set, the default version given in the source code is used (currently version 3). To avoid breakages with index versions other than [23], also set the index version under which t2104 is run to 3. This test only tests functionality specific to version 2 and 3 of the index file and would fail if the test suite is run with any other version. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Gummerer committed Feb 23, 2014 at 21:49 UTC 5d9fc888b485caa1b6a95f2cb583dc26ab7e8d13
4 files changed +20
Makefile
+7
@@ -342,6 +342,10 @@ all::
342 # Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
343 # (defaults to "man") if you want to have a different default when
344 # "git help" is called without a parameter specifying the format.
345 +#
346 +# Define TEST_GIT_INDEX_VERSION to 2, 3 or 4 to run the test suite
347 +# with a different indexfile format version. If it isn't set the index
348 +# file format used is index-v[23].
349
350 GIT-VERSION-FILE: FORCE
351 @$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -2222,6 +2226,9 @@ endif
2226 ifdef GIT_PERF_MAKE_OPTS
2227 @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
2228 endif
2229 +ifdef TEST_GIT_INDEX_VERSION
2230 + @echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@
2231 +endif
2232
2233 ### Detect Python interpreter path changes
2234 ifndef NO_PYTHON
t/t2104-update-index-skip-worktree.sh
+2
@@ -7,6 +7,8 @@ test_description='skip-worktree bit test'
7
8 . ./test-lib.sh
9
10 +test_set_index_version 3
11 +
12 cat >expect.full <<EOF
13 H 1
14 H 2
t/test-lib-functions.sh
+5
@@ -32,6 +32,11 @@ test_set_editor () {
32 export EDITOR
33 }
34
35 +test_set_index_version () {
36 + GIT_INDEX_VERSION="$1"
37 + export GIT_INDEX_VERSION
38 +}
39 +
40 test_decode_color () {
41 awk '
42 function name(n) {
t/test-lib.sh
+6
@@ -108,6 +108,12 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
108 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
109 export EDITOR
110
111 +if test -n "${TEST_GIT_INDEX_VERSION:+isset}"
112 +then
113 + GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION"
114 + export GIT_INDEX_VERSION
115 +fi
116 +
117 # Add libc MALLOC and MALLOC_PERTURB test
118 # only if we are not executing the test with valgrind
119 if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||