Skip to content

Commit 5d9fc88

Browse files
tgummerergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gummerer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 136347d commit 5d9fc88

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ all::
342342
# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
343343
# (defaults to "man") if you want to have a different default when
344344
# "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].
345349

346350
GIT-VERSION-FILE: FORCE
347351
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -2222,6 +2226,9 @@ endif
22222226
ifdef GIT_PERF_MAKE_OPTS
22232227
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
22242228
endif
2229+
ifdef TEST_GIT_INDEX_VERSION
2230+
@echo TEST_GIT_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(TEST_GIT_INDEX_VERSION)))'\' >>$@
2231+
endif
22252232

22262233
### Detect Python interpreter path changes
22272234
ifndef NO_PYTHON

t/t2104-update-index-skip-worktree.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ test_description='skip-worktree bit test'
77

88
. ./test-lib.sh
99

10+
test_set_index_version 3
11+
1012
cat >expect.full <<EOF
1113
H 1
1214
H 2

t/test-lib-functions.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ test_set_editor () {
3232
export EDITOR
3333
}
3434

35+
test_set_index_version () {
36+
GIT_INDEX_VERSION="$1"
37+
export GIT_INDEX_VERSION
38+
}
39+
3540
test_decode_color () {
3641
awk '
3742
function name(n) {

t/test-lib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
108108
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
109109
export EDITOR
110110

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+
111117
# Add libc MALLOC and MALLOC_PERTURB test
112118
# only if we are not executing the test with valgrind
113119
if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||

0 commit comments

Comments
 (0)