test-lib functions: add --printf option to test_commit
Add a --printf option to test_commit to allow writing to the file with
"printf" instead of "echo".
This is useful for writing "\n", "\0" etc., in particular in
combination with the --append option added in 3373518cc8 (test-lib
functions: add an --append option to test_commit, 2021-01-12).
I'm converting a few tests to use the new option rather than a manual
printf/add/commit combination to demonstrate its usefulness. While I'm
at it use "test_create_repo" where appropriate, and give the
first/second commit a meaningful/more conventional log message in
cases where no test cared about that message.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8cfe386b78
commit
47c88d16ba
@ -26,12 +26,8 @@ EOF
|
||||
chmod +x hexdump
|
||||
|
||||
test_expect_success 'setup binary file with history' '
|
||||
printf "\\0\\n" >file &&
|
||||
git add file &&
|
||||
git commit -m one &&
|
||||
printf "\\01\\n" >>file &&
|
||||
git add file &&
|
||||
git commit -m two
|
||||
test_commit --printf one file "\\0\\n" &&
|
||||
test_commit --printf --append two file "\\01\\n"
|
||||
'
|
||||
|
||||
test_expect_success 'file is considered binary by porcelain' '
|
||||
|
||||
Reference in New Issue
Block a user