On Sun, Aug 18, 2019 at 3:21 PM brian m. carlson
<[email protected]> wrote:
> Abstract away the SHA-1-specific constants by sanitizing diff output to
> remove the index lines, since it's clear from the assertions in question
> that we are not interested in the specific object IDs.
>
> Signed-off-by: brian m. carlson <[email protected]>
> ---
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> @@ -7,6 +7,18 @@ test_description='Test git stash'
> +diff_cmp () {
> + for i in "$1" "$2"
> + do
> + sed -e 's/^index 0000000\.\.[0-9a-f]*/index
> 0000000..1234567/' \
> + -e 's/^index [0-9a-f]*\.\.[0-9a-f]*/index 1234567..89abcde/' \
> + -e 's/^index [0-9a-f]*,[0-9a-f]*\.\.[0-9a-f]*/index
> 1234567,7654321..89abcde/' \
> + "$i" > "$i.compare"
> + done &&
> + test_cmp "$1.compare" "$2.compare" &&
> + rm -f "$1.compare" "$2.compare"
> +}
For safety, it would probably be a good idea to check the exit status
of the 'sed' invocation in the for-loop:
for i in "$1" "$2"
do
sed -e ... "$i" >"$i.compare" || return 1
done &&
...
(Note, also, that I dropped the whitespace after the '>' operator.)