Re: [PATCH v4 1/2] t1092: add tests for `git diff-files`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 9, 2023, 23:40 UTC
- Message-ID
- <xmqq356d8pdg.fsf@gitster.g>
- In-Reply-To
- <CAMO4yUFs5zSafO1pGFZqBU9R58G8ENhfTh5qNayeFMRPrCa+Jg@mail.gmail.com>
Shuqi Liang <cheskaqiqi@gmail.com> writes:
Show 7 quoted lines
> I wonder if the method below is good to test the actual output for ' > file present on-disk with modifications' : > > cat >expect <<-EOF && > :100644 100644 8e27be7d6154a1f68ea9160ef0e18691d20560dc > 0000000000000000000000000000000000000000 M newdirectory/testfile > EOF
Hardcoding 8e27be assumes we only support SHA-1 but there is a CI test job that runs everything in SHA-256 mode, so it is likely to break if you wrote it like so. Something along the lines of ...
FN=newdirectory/testfile && OID=$(git hash-object $FN) && ZERO=$(test_oid zero) && echo ":100644 100644 $OID $ZERO M new $FN" >expect
... may have a better chance to be correct, but I didn't test ;-)