From: Oleg Broytman Date: Mon, 15 Jun 2015 03:15:38 +0000 (+0300) Subject: Rename touch-all -> set-commit-date X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=b5a65bd2ca9eb6887fbb3f94ae5c6f262e7d38dc Rename touch-all -> set-commit-date --- diff --git a/hooks/post-checkout/touch b/hooks/post-checkout/set-last-commit-date similarity index 63% rename from hooks/post-checkout/touch rename to hooks/post-checkout/set-last-commit-date index 2c5e625..a39bca4 100755 --- a/hooks/post-checkout/touch +++ b/hooks/post-checkout/set-last-commit-date @@ -1,7 +1,7 @@ #!/bin/sh -# post-checkout hook that changes timestamps on files to that one of the commit -# if branch was changed +# post-checkout hook that changes timestamps on known files +# to that one of the last commit (head) if branch was changed prev_HEAD="$1" new_HEAD="$2" diff --git a/hooks/post-checkout/set-last-commit-date-all b/hooks/post-checkout/set-last-commit-date-all new file mode 100755 index 0000000..e950e4c --- /dev/null +++ b/hooks/post-checkout/set-last-commit-date-all @@ -0,0 +1,16 @@ +#!/bin/sh + +# post-checkout hook that changes timestamps on all files +# to that one of the last commit (head) if branch was changed + +prev_HEAD="$1" +new_HEAD="$2" +new_branch="$3" + +if [ "$new_branch" = 1 ]; then + commit_date="`git show --format='%cD' | head -1`" && + find . \( -name .git -type d -prune \) -o \ + -exec touch --date="$commit_date" '{}' \+ +fi + +exit 0 diff --git a/hooks/post-checkout/touch-all b/hooks/post-checkout/touch-all deleted file mode 100755 index 2f5e80c..0000000 --- a/hooks/post-checkout/touch-all +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# post-checkout hook that changes timestamps on files to that one of the commit -# if branch was changed - -prev_HEAD="$1" -new_HEAD="$2" -new_branch="$3" - -if [ "$new_branch" = 1 ]; then - commit_date="`git show --format='%cD' | head -1`" && - find . \( -name .git -type d -prune \) -o -exec touch --date="$commit_date" '{}' \+ -fi - -exit 0 diff --git a/touch-all b/set-commit-date similarity index 73% rename from touch-all rename to set-commit-date index 3c2b213..fcc7539 100755 --- a/touch-all +++ b/set-commit-date @@ -1,6 +1,6 @@ #! /bin/sh -# Recursively find commit date/time for every file in the current directory +# Recursively find commit date/time for every known file in the repository # and set the file's modification time to that date/time. git ls-tree -r --name-only HEAD | while read filename; do diff --git a/set-commit-date-repos b/set-commit-date-repos new file mode 100755 index 0000000..99e04ce --- /dev/null +++ b/set-commit-date-repos @@ -0,0 +1,11 @@ +#! /bin/sh + +# Call set-commit-date on all repositories. + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && + +exec "$prog_dir"/do-all \ + 'test "$g" = "$d/.git" || continue &&' \ + 'cd "$d"; echo "$d"; "$prog_dir"/set-commit-date &&' \ + 'git submodule foreach "$prog_dir"/set-commit-date' diff --git a/touch-ALL-repos b/touch-ALL-repos deleted file mode 100755 index 3454a6e..0000000 --- a/touch-ALL-repos +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -cd "`dirname \"$0\"`" && -prog_dir="`pwd`" && - -exec "$prog_dir"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'echo "$d" && "$prog_dir"/touch-all &&' \ - 'git submodule foreach "$prog_dir"/touch-all'