mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
861dc19ba8
When the destination is read-only, "mv" on some version of macOS asks whether to replace the destination even though in the test its stdin is not a terminal (and thus doesn't conform to POSIX[1]). The helper to corrupt a chunk-file is designed to work on the files like commit-graph and multi-pack-index files that are generally read-only, so use "mv -f" to work around this issue. Helped-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 lines
697 B
Bash
18 lines
697 B
Bash
# Shell library for working with "chunk" files (commit-graph, midx, etc).
|
|
|
|
# corrupt_chunk_file <fn> <chunk> <offset> <bytes>
|
|
#
|
|
# Corrupt a chunk-based file (like a commit-graph) by overwriting the bytes
|
|
# found in the chunk specified by the 4-byte <chunk> identifier. If <offset> is
|
|
# "clear", replace the chunk entirely. Otherwise, overwrite data <offset> bytes
|
|
# into the chunk.
|
|
#
|
|
# The <bytes> are interpreted as pairs of hex digits (so "000000FE" would be
|
|
# big-endian 254).
|
|
corrupt_chunk_file () {
|
|
fn=$1; shift
|
|
perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
|
|
"$@" <"$fn" >"$fn.tmp" &&
|
|
# some vintages of macOS 'mv' fails to overwrite a read-only file.
|
|
mv -f "$fn.tmp" "$fn"
|
|
}
|