Merge branch 'jx/t6020-with-older-bash'

Work around inefficient glob substitution in older versions of bash
by rewriting parts of a test.

* jx/t6020-with-older-bash:
  t6020: fix incompatible parameter expansion
This commit is contained in:
Junio C Hamano 2021-07-08 13:14:59 -07:00
commit 102969c422

View File

@ -80,30 +80,42 @@ test_commit_setvar () {
eval $var=$oid
}
get_abbrev_oid () {
oid=$1 &&
suffix=${oid#???????} &&
oid=${oid%$suffix} &&
if test -n "$oid"
then
echo "$oid"
else
echo "undefined-oid"
fi
}
# Format the output of git commands to make a user-friendly and stable
# text. We can easily prepare the expect text without having to worry
# about future changes of the commit ID and spaces of the output.
make_user_friendly_and_stable_output () {
sed \
-e "s/${A%${A#???????}}[0-9a-f]*/<COMMIT-A>/g" \
-e "s/${B%${B#???????}}[0-9a-f]*/<COMMIT-B>/g" \
-e "s/${C%${C#???????}}[0-9a-f]*/<COMMIT-C>/g" \
-e "s/${D%${D#???????}}[0-9a-f]*/<COMMIT-D>/g" \
-e "s/${E%${E#???????}}[0-9a-f]*/<COMMIT-E>/g" \
-e "s/${F%${F#???????}}[0-9a-f]*/<COMMIT-F>/g" \
-e "s/${G%${G#???????}}[0-9a-f]*/<COMMIT-G>/g" \
-e "s/${H%${H#???????}}[0-9a-f]*/<COMMIT-H>/g" \
-e "s/${I%${I#???????}}[0-9a-f]*/<COMMIT-I>/g" \
-e "s/${J%${J#???????}}[0-9a-f]*/<COMMIT-J>/g" \
-e "s/${K%${K#???????}}[0-9a-f]*/<COMMIT-K>/g" \
-e "s/${L%${L#???????}}[0-9a-f]*/<COMMIT-L>/g" \
-e "s/${M%${M#???????}}[0-9a-f]*/<COMMIT-M>/g" \
-e "s/${N%${N#???????}}[0-9a-f]*/<COMMIT-N>/g" \
-e "s/${O%${O#???????}}[0-9a-f]*/<COMMIT-O>/g" \
-e "s/${P%${P#???????}}[0-9a-f]*/<COMMIT-P>/g" \
-e "s/${TAG1%${TAG1#???????}}[0-9a-f]*/<TAG-1>/g" \
-e "s/${TAG2%${TAG2#???????}}[0-9a-f]*/<TAG-2>/g" \
-e "s/${TAG3%${TAG3#???????}}[0-9a-f]*/<TAG-3>/g" \
-e "s/$(get_abbrev_oid $A)[0-9a-f]*/<COMMIT-A>/g" \
-e "s/$(get_abbrev_oid $B)[0-9a-f]*/<COMMIT-B>/g" \
-e "s/$(get_abbrev_oid $C)[0-9a-f]*/<COMMIT-C>/g" \
-e "s/$(get_abbrev_oid $D)[0-9a-f]*/<COMMIT-D>/g" \
-e "s/$(get_abbrev_oid $E)[0-9a-f]*/<COMMIT-E>/g" \
-e "s/$(get_abbrev_oid $F)[0-9a-f]*/<COMMIT-F>/g" \
-e "s/$(get_abbrev_oid $G)[0-9a-f]*/<COMMIT-G>/g" \
-e "s/$(get_abbrev_oid $H)[0-9a-f]*/<COMMIT-H>/g" \
-e "s/$(get_abbrev_oid $I)[0-9a-f]*/<COMMIT-I>/g" \
-e "s/$(get_abbrev_oid $J)[0-9a-f]*/<COMMIT-J>/g" \
-e "s/$(get_abbrev_oid $K)[0-9a-f]*/<COMMIT-K>/g" \
-e "s/$(get_abbrev_oid $L)[0-9a-f]*/<COMMIT-L>/g" \
-e "s/$(get_abbrev_oid $M)[0-9a-f]*/<COMMIT-M>/g" \
-e "s/$(get_abbrev_oid $N)[0-9a-f]*/<COMMIT-N>/g" \
-e "s/$(get_abbrev_oid $O)[0-9a-f]*/<COMMIT-O>/g" \
-e "s/$(get_abbrev_oid $P)[0-9a-f]*/<COMMIT-P>/g" \
-e "s/$(get_abbrev_oid $TAG1)[0-9a-f]*/<TAG-1>/g" \
-e "s/$(get_abbrev_oid $TAG2)[0-9a-f]*/<TAG-2>/g" \
-e "s/$(get_abbrev_oid $TAG3)[0-9a-f]*/<TAG-3>/g" \
-e "s/ *\$//"
}