git/t/helper
Derrick Stolee d96075428a multi-pack-index: use hash version byte
Similar to the commit-graph format, the multi-pack-index format has a
byte in the header intended to track the hash version used to write the
file. This allows one to interpret the hash length without having the
context of the repository config specifying the hash length. This was
not modified as part of the SHA-256 work because the hash length was
automatically up-shifted due to that config.

Since we have this byte available, we can make the file formats more
obviously incompatible instead of relying on other context from the
repository.

Add a new oid_version() method in midx.c similar to the one in
commit-graph.c. This is specifically made separate from that
implementation to avoid artificially linking the formats.

The test impact requires a few more things than the corresponding change
in the commit-graph format. Specifically, 'test-tool read-midx' was not
writing anything about this header value to output. Since the value
available in 'struct multi_pack_index' is hash_len instead of a version
value, we output "20" or "32" instead of "1" or "2".

Since we want a user to not have their Git commands fail if their
multi-pack-index has the incorrect hash version compared to the
repository's hash version, we relax the die() to an error() in
load_multi_pack_index(). This has some effect on 'git multi-pack-index
verify' as we need to check that a failed parse of a file that exists is
actually a verify error. For that test that checks the hash version
matches, we change the corrupted byte from "2" to "3" to ensure the test
fails for both hash algorithms.

Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-08-17 16:45:20 -07:00
..
.gitignore t/helper: ignore only executable files 2019-09-20 11:13:13 -07:00
test-advise.c advice: revamp advise API 2020-03-05 06:15:02 -08:00
test-bloom.c t: make test-bloom initialize repository 2020-07-30 09:16:45 -07:00
test-chmtime.c Merge branch 'ps/test-chmtime-get' 2018-04-25 13:29:00 +09:00
test-config.c config: provide access to the current line number 2020-02-10 10:52:10 -08:00
test-ctype.c
test-date.c test_date.c: remove reference to GIT_TEST_DATE_NOW 2019-09-18 14:15:01 -07:00
test-delta.c test-delta: read input into a heap buffer 2018-08-30 10:30:21 -07:00
test-dir-iterator.c Merge branch 'mt/dir-iterator-updates' 2019-08-09 10:13:14 -07:00
test-drop-caches.c Sync with 2.17.3 2019-12-06 16:29:15 +01:00
test-dump-cache-tree.c convert "oidcmp() != 0" to "!oideq()" 2018-08-29 11:32:49 -07:00
test-dump-fsmonitor.c fsmonitor: change last update timestamp on the index_state to opaque token 2020-01-13 14:58:43 -08:00
test-dump-split-index.c t/helper/test-dump-split-index: initialize git repository 2020-02-24 09:33:24 -08:00
test-dump-untracked-cache.c cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch 2019-01-24 11:55:06 -08:00
test-example-decorate.c object: convert lookup_unknown_object() to use object_id 2019-06-20 10:06:19 -07:00
test-fake-ssh.c
test-genrandom.c
test-genzeros.c tests: teach the test-tool to generate NUL bytes and use it 2019-02-19 10:22:21 -08:00
test-hash-speed.c t/helper: add a test helper to compute hash speed 2018-11-14 16:54:52 +09:00
test-hash.c t: make the sha1 test-tool helper generic 2018-11-14 16:54:52 +09:00
test-hashmap.c hashmap_entry: remove first member requirement from docs 2019-10-07 10:20:12 +09:00
test-index-version.c
test-json-writer.c json_writer: new routines to create JSON data 2018-07-16 13:55:39 -07:00
test-lazy-init-name-hash.c OFFSETOF_VAR macro to simplify hashmap iterators 2019-10-07 10:20:11 +09:00
test-line-buffer.c
test-match-trees.c match-trees.c: remove the_repo from shift_tree*() 2019-06-27 12:45:17 -07:00
test-mergesort.c
test-mktemp.c
test-oid-array.c t/helper: initialize the repository for test-sha1-array 2020-06-19 14:04:08 -07:00
test-oidmap.c test-oidmap: remove 'add' subcommand 2019-07-01 10:26:28 -07:00
test-online-cpus.c
test-parse-options.c parse-options: add testcases for OPT_CMDMODE() 2020-02-20 13:20:40 -08:00
test-parse-pathspec-file.c test-parse-pathspec-file.c: s/0/NULL/ for pointer type 2020-04-27 11:21:12 -07:00
test-path-utils.c real_path: remove unsafe API 2020-03-10 11:41:40 -07:00
test-pkt-line.c pkt-line: define PACKET_READ_RESPONSE_END 2020-05-24 16:26:00 -07:00
test-prio-queue.c test-prio-queue: use xmalloc 2019-04-12 13:34:17 +09:00
test-progress.c progress.c: silence cgcc suggestion about internal linkage 2020-04-27 11:21:28 -07:00
test-reach.c Merge branch 'cb/is-descendant-of' 2020-07-06 22:09:16 -07:00
test-read-cache.c test-read-cache: drop namelen variable 2019-09-06 11:03:39 -07:00
test-read-graph.c Merge branch 'gs/commit-graph-path-filter' 2020-05-01 13:39:53 -07:00
test-read-midx.c multi-pack-index: use hash version byte 2020-08-17 16:45:20 -07:00
test-ref-store.c worktree: drop get_worktrees() unused 'flags' argument 2020-06-22 10:31:15 -07:00
test-regex.c t/helper: teach test-regex to report pattern errors (like REG_ILLSEQ) 2020-05-18 13:03:35 -07:00
test-repository.c t/helper: make repository tests hash independent 2020-02-24 09:33:27 -08:00
test-revision-walking.c revision.c: remove implicit dependency on the_index 2018-09-21 09:51:19 -07:00
test-run-command.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
test-scrap-cache-tree.c Merge branch 'ma/lockfile-cleanup' 2018-05-30 14:04:05 +09:00
test-serve-v2.c Turn git serve into a test helper 2019-04-19 14:03:24 +09:00
test-sha1.c t: make the sha1 test-tool helper generic 2018-11-14 16:54:52 +09:00
test-sha1.sh
test-sha256.c Add a base implementation of SHA-256 support 2018-11-14 16:54:53 +09:00
test-sigchain.c style: the opening '{' of a function is in a separate line 2018-12-10 15:41:09 +09:00
test-strcmp-offset.c t/helper: merge test-strcmp-offset into test-tool 2018-03-27 08:45:47 -07:00
test-string-list.c t/helper: merge test-string-list into test-tool 2018-03-27 08:45:47 -07:00
test-submodule-config.c Merge branch 'sb/submodule-move-nested' 2018-05-08 15:59:17 +09:00
test-submodule-nested-repo-config.c repository: repo_submodule_init to take a submodule struct 2018-12-05 11:42:32 +09:00
test-subprocess.c t/helper: merge test-subprocess into test-tool 2018-03-27 08:45:47 -07:00
test-svn-fe.c
test-tool.c Merge branch 'gs/commit-graph-path-filter' 2020-05-01 13:39:53 -07:00
test-tool.h Merge branch 'gs/commit-graph-path-filter' 2020-05-01 13:39:53 -07:00
test-trace2.c strvec: rename files from argv-array to strvec 2020-07-28 15:02:17 -07:00
test-urlmatch-normalization.c t/helper: merge test-urlmatch-normalization into test-tool 2018-03-27 08:45:47 -07:00
test-wildmatch.c t/helper: merge test-wildmatch into test-tool 2018-03-27 08:45:47 -07:00
test-windows-named-pipe.c use strpbrk(3) to search for characters from a given set 2020-02-24 09:30:31 -08:00
test-write-cache.c Merge branch 'ma/lockfile-cleanup' 2018-05-30 14:04:05 +09:00
test-xml-encode.c tests: optionally write results as JUnit-style .xml 2019-01-29 09:26:46 -08:00