From: Oleg Broytman Date: Mon, 22 Jan 2024 16:02:50 +0000 (+0300) Subject: Fix(set-last-commit-date): Use `git show -s` X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=11d28be70b2911af2c1f197be5ba83c0ca5cdfa2 Fix(set-last-commit-date): Use `git show -s` --- diff --git a/hooks/post-checkout/set-last-commit-date-all b/hooks/post-checkout/set-last-commit-date-all index e950e4c..1c87fba 100755 --- a/hooks/post-checkout/set-last-commit-date-all +++ b/hooks/post-checkout/set-last-commit-date-all @@ -8,7 +8,7 @@ new_HEAD="$2" new_branch="$3" if [ "$new_branch" = 1 ]; then - commit_date="`git show --format='%cD' | head -1`" && + commit_date="`git show --format='%cD' -s`" && find . \( -name .git -type d -prune \) -o \ -exec touch --date="$commit_date" '{}' \+ fi diff --git a/hooks/post-checkout/set-last-commit-date-changed b/hooks/post-checkout/set-last-commit-date-changed index 4074707..1a6b0ac 100755 --- a/hooks/post-checkout/set-last-commit-date-changed +++ b/hooks/post-checkout/set-last-commit-date-changed @@ -8,7 +8,7 @@ new_HEAD="$2" new_branch="$3" if [ "$new_branch" = 1 ]; then - commit_date="`git show --format='%cD' | head -1`" && + commit_date="`git show --format='%cD' -s`" && touch --date="$commit_date" `git diff --name-only HEAD~` fi diff --git a/hooks/post-checkout/set-last-commit-date-committed b/hooks/post-checkout/set-last-commit-date-committed index a39bca4..1e88974 100755 --- a/hooks/post-checkout/set-last-commit-date-committed +++ b/hooks/post-checkout/set-last-commit-date-committed @@ -8,7 +8,7 @@ new_HEAD="$2" new_branch="$3" if [ "$new_branch" = 1 ]; then - commit_date="`git show --format='%cD' | head -1`" && + commit_date="`git show --format='%cD' -s`" && touch --date="$commit_date" `git ls-files --cached` fi