Skip to content

Commit ae368ba

Browse files
committed
test_git.sh: use parameter expansion instead of sed
Fixes SC2001. Part of #891.
1 parent 2ee13eb commit ae368ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test_git.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -744,29 +744,29 @@ function git::rev_parse_sha() {
744744
git add file_1
745745
git commit -qam 'commit_1'
746746
SHA1="$(git rev-parse HEAD)"
747-
SHORT1="$(echo "$SHA1" | sed 's/........$//')"
747+
SHORT1="${SHA1%????????}"
748748

749749
# Another commit on branch 1 (at HEAD)
750750
date > file_2
751751
git add file_2
752752
git commit -qam 'commit_2'
753753
SHA2="$(git rev-parse HEAD)"
754-
SHORT2="$(echo "$SHA2" | sed 's/........$//')"
754+
SHORT2="${SHA2%????????}"
755755

756756
# A commit on branch 2 (not at HEAD)
757757
git checkout -b branch_2
758758
date > file_3
759759
git add file_3
760760
git commit -qam 'commit_3'
761761
SHA3="$(git rev-parse HEAD)"
762-
SHORT3="$(echo "$SHA3" | sed 's/........$//')"
762+
SHORT3="${SHA3%????????}"
763763

764764
# Another commit on branch 2 (at HEAD)
765765
date > file_4
766766
git add file_4
767767
git commit -qam 'commit_4'
768768
SHA4="$(git rev-parse HEAD)"
769-
SHORT4="$(echo "$SHA4" | sed 's/........$//')"
769+
SHORT4="${SHA4%????????}"
770770

771771
assert_eq "$(git rev-parse "$SHA1")" "$SHA1"
772772
assert_eq "$(git rev-parse "$SHA1^{commit}")" "$SHA1"

0 commit comments

Comments
 (0)