From 91f4e4d5ca15f1ff80cc0f17b2bd4474a753c403 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 9 Jan 2025 14:44:06 +0300 Subject: [PATCH] Refactor: `git show --format=` -> `git show --pretty=format:` --- hooks/post-checkout/set-last-commit-date-all | 2 +- hooks/post-checkout/set-last-commit-date-changed | 2 +- hooks/post-checkout/set-last-commit-date-committed | 2 +- set-commit-date | 2 +- set-commit-date.py | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hooks/post-checkout/set-last-commit-date-all b/hooks/post-checkout/set-last-commit-date-all index 1c87fba..4cceb0f 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' -s`" && + commit_date="`git show --pretty=tformat:'%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 1a6b0ac..267711e 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' -s`" && + commit_date="`git show --pretty=tformat:'%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 1e88974..f55ea77 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' -s`" && + commit_date="`git show --pretty=tformat:'%cD' -s`" && touch --date="$commit_date" `git ls-files --cached` fi diff --git a/set-commit-date b/set-commit-date index fcc7539..db48c59 100755 --- a/set-commit-date +++ b/set-commit-date @@ -4,5 +4,5 @@ # and set the file's modification time to that date/time. git ls-tree -r --name-only HEAD | while read filename; do - touch --date="`git log -1 --format=\"%cD\" -- \"$filename\"`" "$filename" + touch --date="`git log -1 --pretty=tformat:\"%cD\" -- \"$filename\"`" "$filename" done diff --git a/set-commit-date.py b/set-commit-date.py index c0aaa8c..67d2c4f 100755 --- a/set-commit-date.py +++ b/set-commit-date.py @@ -34,7 +34,8 @@ separator = '----- GIT LOG SEPARATOR -----' git_log = subprocess.Popen(['git', 'log', '-m', '--first-parent', '--name-status', '--no-color', - '--format=%s%%n%%%st' % (separator, date_format)], + '--pretty=tformat:%s%%n%%%st' % ( + separator, date_format)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) changed_files = set() -- 2.39.5