From 01e28e13fb52b56556cf615ae658c48842c94303 Mon Sep 17 00:00:00 2001 From: Chris Darroch Date: Sun, 14 Jan 2024 22:31:58 -0800 Subject: [PATCH] t/t-smudge.sh: test smudge spooling to temp file In a prior commit in this PR we updated the tools.Spool() function, which is used only by the "git lfs smudge" command and only when it must pass through non-pointer data. When this data is longer than the default internal memory buffer of 1024 bytes, the Spool() function creates a temporary file to buffer the data, and then defers an os.Remove() call to delete the file when the operation is complete. At present this use of a temporary file when spooling is not tested by the t/t-smudge.sh test suite, so we add a check in the existing "smudge with invalid pointer" test which forces the use of such a file by sending more than 1024 bytes of non-pointer data. --- t/t-smudge.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/t-smudge.sh b/t/t-smudge.sh index 07e4215f..738ea8e5 100755 --- a/t/t-smudge.sh +++ b/t/t-smudge.sh @@ -54,6 +54,10 @@ begin_test "smudge with invalid pointer" [ "wat" = "$(echo "wat" | git lfs smudge)" ] [ "not a git-lfs file" = "$(echo "not a git-lfs file" | git lfs smudge)" ] [ "version " = "$(echo "version " | git lfs smudge)" ] + + # force use of a spool file with non-pointer input longer than max buffer + spool="$(base64 < /dev/urandom | head -c 2048)" + [ "$spool" = "$(echo "$spool" | git lfs smudge)" ] ) end_test