From e5e2c6fbf9337219edb79ce97b56b3be91bc14e5 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Thu, 28 Nov 2024 08:27:38 -0500 Subject: [PATCH 1/2] Fix a few ShellCheck warnings and stylistic inconsistencies This was originally intended to be part of much broader changes, to more scripts, along the same lines, and adding a ShellCheck CI job. That will likely still happen, but it's not clear when it will get done. Rather than wait, this brings in the small benefits of these changes. --- etc/check-package-size.sh | 10 +-- .../fixtures/make_attributes_baseline.sh | 81 ++++++++++--------- .../fixtures/generate_git_date_baseline.sh | 28 +++---- .../fuzz_commit_corpus_builder.sh | 16 ++-- .../fuzz_targets/fuzz_tag_corpus_builder.sh | 16 ++-- .../fuzz_targets/fuzz_tree_corpus_builder.sh | 16 ++-- 6 files changed, 84 insertions(+), 83 deletions(-) diff --git a/etc/check-package-size.sh b/etc/check-package-size.sh index c23bad23336..3a05c237c0e 100755 --- a/etc/check-package-size.sh +++ b/etc/check-package-size.sh @@ -4,17 +4,17 @@ set -eu -o pipefail function enter () { local dir="${1:?need directory to enter}" - echo -n $' in' $dir $'\t→\t' - cd $dir + printf ' in %s \t→\t' "$dir" + cd -- "$dir" } function indent () { - "$@" | grep "package size" | while read -r line; do - echo " " $line + "$@" | grep -F 'package size' | while IFS= read -r line; do + echo " $line" done } -echo "in root: gitoxide CLI" +echo 'in root: gitoxide CLI' (enter gix-fsck && indent cargo diet -n --package-size-limit 10KB) (enter gix-actor && indent cargo diet -n --package-size-limit 10KB) (enter gix-archive && indent cargo diet -n --package-size-limit 10KB) diff --git a/gix-attributes/tests/fixtures/make_attributes_baseline.sh b/gix-attributes/tests/fixtures/make_attributes_baseline.sh index 47f109e971d..c31d78fbe9f 100755 --- a/gix-attributes/tests/fixtures/make_attributes_baseline.sh +++ b/gix-attributes/tests/fixtures/make_attributes_baseline.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash set -eu -o pipefail -mkdir basics; +mkdir basics function baseline() { { echo "$1" - GIT_ATTR_NOSYSTEM=1 git -c core.attributesFile=$PWD/user.attributes check-attr -a "$1" + GIT_ATTR_NOSYSTEM=1 git -c core.attributesFile="$PWD/user.attributes" check-attr -a "$1" echo } >> baseline } @@ -17,39 +17,40 @@ function baseline() { # based on https://github.com/git/git/blob/140b9478dad5d19543c1cb4fd293ccec228f1240/t/t0003-attributes.sh#L45 mkdir -p a/b/d a/c b - ( - echo "[attr]notest !test" - echo "\" d \" test=d" - echo " e test=e" - echo " e\" test=e" - echo "f test=f" - echo "a/i test=a/i" - echo "onoff test -test" - echo "offon -test test" - echo "no notest" - echo "A/e/F test=A/e/F" - echo "\!escaped test-escaped" - echo "**/recursive test-double-star-slash" - echo "a**f test-double-star-no-slash" - echo "dir-slash/ never" - echo "dir/** always" - ) > .gitattributes - ( - echo "g test=a/g" - echo "b/g test=a/b/g" - ) > a/.gitattributes - ( - echo "h test=a/b/h" - echo "d/* test=a/b/d/*" - echo "d/yes notest" - ) > a/b/.gitattributes - ( - echo "global test=global" - echo "z/x/a global-no-wildcard-case-test" - echo "z/x/* global-wildcard-case-test" - ) > user.attributes + { + echo '[attr]notest !test' + echo '" d " test=d' + echo ' e test=e' + echo ' e" test=e' + echo 'f test=f' + echo 'a/i test=a/i' + echo 'onoff test -test' + echo 'offon -test test' + echo 'no notest' + echo 'A/e/F test=A/e/F' + echo '\!escaped test-escaped' + echo '**/recursive test-double-star-slash' + echo 'a**f test-double-star-no-slash' + echo 'dir-slash/ never' + echo 'dir/** always' + } > .gitattributes + { + echo 'g test=a/g' + echo 'b/g test=a/b/g' + } > a/.gitattributes + { + echo 'h test=a/b/h' + echo 'd/* test=a/b/d/*' + echo 'd/yes notest' + } > a/b/.gitattributes + { + echo 'global test=global' + echo 'z/x/a global-no-wildcard-case-test' + echo 'z/x/* global-wildcard-case-test' + } > user.attributes - git add . && git commit -qm c1 + git add . + git commit -qm c1 baseline z/x/a baseline Z/x/a @@ -67,7 +68,7 @@ function baseline() { baseline a/recursive baseline a/b/recursive baseline a/b/c/recursive - baseline "!escaped" + baseline '!escaped' baseline af baseline axf baseline a/b/d/no @@ -77,7 +78,7 @@ function baseline() { baseline a/B/D/g baseline b/g baseline a/c/f - baseline "e\"" + baseline 'e"' baseline a/i baseline A/b/h baseline A/B/D/NO @@ -100,23 +101,23 @@ mkdir lookup-order (cd lookup-order function baseline_selected() { - local path=${1?first argument is the path to match} + local path="${1?first argument is the path to match}" shift { echo "$path" - git -c core.attributesFile=$PWD/user.attributes check-attr $@ -- "$path" + git -c core.attributesFile="$PWD/user.attributes" check-attr "$@" -- "$path" echo } >> baseline.selected } git init - cat < user.attributes + cat <<'EOF' > user.attributes [attr]my-text text [attr]my-binary binary * location=user EOF - cat < .gitattributes + cat <<'EOF' > .gitattributes [attr]b-cycle a-cycle my-text [attr]a-cycle b-cycle my-binary [attr]recursive recursively-assigned-attr diff --git a/gix-date/tests/fixtures/generate_git_date_baseline.sh b/gix-date/tests/fixtures/generate_git_date_baseline.sh index 45d5217b6a9..1b241350b1d 100755 --- a/gix-date/tests/fixtures/generate_git_date_baseline.sh +++ b/gix-date/tests/fixtures/generate_git_date_baseline.sh @@ -1,23 +1,24 @@ #!/usr/bin/env bash set -eu -o pipefail -git init; +git init function baseline() { - local test_date=$1 # first argument is the date to test - local test_name=$2 # second argument is the format name for re-formatting + local test_date="$1" # first argument is the date to test + local test_name="$2" # second argument is the format name for re-formatting + + local status=0 + git -c section.key="$test_date" config --type=expiry-date section.key || status="$?" - git -c section.key="$test_date" config --type=expiry-date section.key && status=0 || status=$? { - echo "$test_date" - echo "$test_name" - echo "$status" - if [ $status == 0 ] - then - git -c section.key="$test_date" config --type=expiry-date section.key - else - echo "-1" - fi + echo "$test_date" + echo "$test_name" + echo "$status" + if [ "$status" = 0 ]; then + git -c section.key="$test_date" config --type=expiry-date section.key + else + echo '-1' + fi } >> baseline.git } @@ -43,4 +44,3 @@ baseline '1234567890' 'UNIX' baseline '1660874655 +0800' 'RAW' # Note that we can't necessarily put 64bit dates here yet as `git` on the system might not yet support it. - diff --git a/gix-object/fuzz/fuzz_targets/fuzz_commit_corpus_builder.sh b/gix-object/fuzz/fuzz_targets/fuzz_commit_corpus_builder.sh index 333448859bb..92044d9ab20 100755 --- a/gix-object/fuzz/fuzz_targets/fuzz_commit_corpus_builder.sh +++ b/gix-object/fuzz/fuzz_targets/fuzz_commit_corpus_builder.sh @@ -1,12 +1,12 @@ -#!/usr/bin/bash +#!/usr/bin/env bash -set -eox pipefail +set -eux -o pipefail -ROOT=$1 -OUTPUT_CORPUS=$2 -FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/commit) +root="$1" +output_corpus="$2" +fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/commit")" -echo $ROOT -echo $FIXTURES_DIR +echo "$root" +echo "$fixtures_dir" -zip -j $OUTPUT_CORPUS $FIXTURES_DIR/* +zip -j "$output_corpus" "$fixtures_dir"/* diff --git a/gix-object/fuzz/fuzz_targets/fuzz_tag_corpus_builder.sh b/gix-object/fuzz/fuzz_targets/fuzz_tag_corpus_builder.sh index 5c4bafac585..9bf588b46b9 100755 --- a/gix-object/fuzz/fuzz_targets/fuzz_tag_corpus_builder.sh +++ b/gix-object/fuzz/fuzz_targets/fuzz_tag_corpus_builder.sh @@ -1,12 +1,12 @@ -#!/usr/bin/bash +#!/usr/bin/env bash -set -eox pipefail +set -eux -o pipefail -ROOT=$1 -OUTPUT_CORPUS=$2 -FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/tag) +root="$1" +output_corpus="$2" +fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/tag")" -echo $ROOT -echo $FIXTURES_DIR +echo "$root" +echo "$fixtures_dir" -zip -j $OUTPUT_CORPUS $FIXTURES_DIR/* +zip -j "$output_corpus" "$fixtures_dir"/* diff --git a/gix-object/fuzz/fuzz_targets/fuzz_tree_corpus_builder.sh b/gix-object/fuzz/fuzz_targets/fuzz_tree_corpus_builder.sh index dac2aa33974..cc458e67fc3 100755 --- a/gix-object/fuzz/fuzz_targets/fuzz_tree_corpus_builder.sh +++ b/gix-object/fuzz/fuzz_targets/fuzz_tree_corpus_builder.sh @@ -1,12 +1,12 @@ -#!/usr/bin/bash +#!/usr/bin/env bash -set -eox pipefail +set -eux -o pipefail -ROOT=$1 -OUTPUT_CORPUS=$2 -FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/tree) +root="$1" +output_corpus="$2" +fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/tree")" -echo $ROOT -echo $FIXTURES_DIR +echo "$root" +echo "$fixtures_dir" -zip -j $OUTPUT_CORPUS $FIXTURES_DIR/* +zip -j "$output_corpus" "$fixtures_dir"/* From 2dbd7ba901245ec17ec9a966e435922fc859292a Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sat, 22 Mar 2025 11:16:10 -0400 Subject: [PATCH 2/2] Add regenerated `generate_git_date_baseline` archive This was regenerated via `cargo nextest --workspace --no-fail-fast` and verifying that there were no failures, then committing the one changed file, on an Arch Linux system with Git 2.49.0. This is the only tracked archive that changes due to the script changes in the previous commit. The other changed scripts are either to scripts whose generated archives are `.gitignore`d, or to scripts that are not fixture scripts (so no archives at all). --- .../generate_git_date_baseline.tar | Bin 50688 -> 50176 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gix-date/tests/fixtures/generated-archives/generate_git_date_baseline.tar b/gix-date/tests/fixtures/generated-archives/generate_git_date_baseline.tar index aced50eb9d7e0d2ff8b7554c75523701c1134282..073cb0db8a36dfea2b2680f77aa0db659517aa04 100644 GIT binary patch delta 175 zcmZqZVQ%PPUcj_z3qJ>wrQT+TX$Kf5D(ElT$HZr5WMN=xU}0&YTbh?yu{m(sdZ3K+ zCMH&<&8%D;Y@2z7elRX(6<}J-x`Jghs|Xv@Vs0I=&D>=y9Gm$w{xEOmc486P%s=A~ z^J4B8p3U3~elc%m4P#^5%-zN!w3$EWKj&sXvA?2=x$8JKbIjt*XtU?@Yn|Y;vFfL}5VA{;8z{a$gyH9K}x02XqZWk7j z&HOokSQm50@GRzbVA;&w!pyaq&w`O-Gyjr5?3=lZScEq7NBm*l%)RCp^J3Nvmc^{w zfLMlQGwUu^rp;XYzA