Skip to content

Commit d40f423

Browse files
committed
🛠 [fix] pre-commit concurrent issue
1 parent 2514df8 commit d40f423

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

bin/chmod-sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -euo pipefail
55
# both the working tree and the index, so Makefile recipes invoking
66
# pkg/**/*.sh do not break on a missing exec bit after fresh checkouts.
77

8-
for f in "$@"; do
9-
chmod +x "$f"
10-
git update-index --chmod=+x -- "$f"
8+
for file in "$@"; do
9+
[[ -x "$file" ]] || chmod +x "$file"
10+
mode=$(git ls-files --stage -- "$file" | awk '{print $1}')
11+
[[ "$mode" == "100755" ]] || git update-index --chmod=+x -- "$file"
1112
done

0 commit comments

Comments
 (0)