]>
Commit | Line | Data |
---|---|---|
86b008ee JK |
1 | # Shell library for working with "chunk" files (commit-graph, midx, etc). |
2 | ||
3 | # corrupt_chunk_file <fn> <chunk> <offset> <bytes> | |
4 | # | |
5 | # Corrupt a chunk-based file (like a commit-graph) by overwriting the bytes | |
6 | # found in the chunk specified by the 4-byte <chunk> identifier. If <offset> is | |
7 | # "clear", replace the chunk entirely. Otherwise, overwrite data <offset> bytes | |
8 | # into the chunk. | |
9 | # | |
10 | # The <bytes> are interpreted as pairs of hex digits (so "000000FE" would be | |
11 | # big-endian 254). | |
12 | corrupt_chunk_file () { | |
13 | fn=$1; shift | |
14 | perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \ | |
15 | "$@" <"$fn" >"$fn.tmp" && | |
861dc19b JH |
16 | # some vintages of macOS 'mv' fails to overwrite a read-only file. |
17 | mv -f "$fn.tmp" "$fn" | |
86b008ee | 18 | } |