From 41df8dc7f322f6b3ac759e10493e2ca92d1194fc Mon Sep 17 00:00:00 2001 From: Bill Wood Date: Thu, 5 May 2022 11:19:30 -0400 Subject: [PATCH] updates per request of spacewander --- Commands.md | 8 +++++--- bin/git-utimes | 4 ++-- check_dependencies.sh | 2 +- man/git-utimes.md | 10 +++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Commands.md b/Commands.md index e6307b6..a644e45 100644 --- a/Commands.md +++ b/Commands.md @@ -1520,9 +1520,9 @@ $ git browse-ci upstream ## git utimes -Change files modification time to their last commit date. Does not touch files that are in the working tree or index. +Change files modification time to their last commit date. Does not touch files that are in the working tree or index. -The `-n` or `--newer` flag preserves the original modification time of files that were committed from the local repo, by only touching files that are newer than their last commit date. +The `--newer` flag preserves the original modification time of files that were committed from the local repo, by only touching files that are newer than their last commit date. ```bash git-extras$ ls -l bin | head @@ -1536,6 +1536,7 @@ total 308 -rwxr-xr-x 1 vt vt 6282 Nov 8 13:56 git-bulk -rwxr-xr-x 1 vt vt 18561 Nov 8 13:56 git-changelog -rwxr-xr-x 1 vt vt 215 Nov 8 13:56 git-clear + git-extras$ git utimes --newer + touch -d 2020-05-22T10:40:29+08:00 bin/git-archive-file + touch -d 2017-05-05T16:02:09+08:00 bin/git-authors @@ -1546,6 +1547,7 @@ git-extras$ git utimes --newer + touch -d 2019-09-05T12:41:38+08:00 bin/git-changelog + touch -d 2016-11-19T16:41:19+00:00 bin/git-clear [...] + git-extras$ ls -l bin | head total 308 -rwxr-xr-x 1 vt vt 489 Jul 28 2015 git-alias @@ -1559,7 +1561,7 @@ total 308 -rwxr-xr-x 1 vt vt 215 Nov 19 2016 git-clear ``` -Note above, `git-alias` was not touched because of the `--newer` flag. +Note above, that because of the `--newer` flag, the file `git-alias` was not touched since its modified date is earlier than the commit date. ## git abort diff --git a/bin/git-utimes b/bin/git-utimes index a872e20..0a5f1f4 100755 --- a/bin/git-utimes +++ b/bin/git-utimes @@ -5,7 +5,7 @@ if [ "$1" = "--touch" ]; then # Internal use option only just to parallelize things. newer_flag="" - [ "$2" = "--newer" ] || [ "$2" = "-n" ] && newer_flag="true" + [ "$2" = "--newer" ] && newer_flag="true" shift 2 bsd=$(date -j > /dev/null 2>&1 && echo 'true') if [ -n "$bsd" ]; then @@ -36,7 +36,7 @@ else # don't touch files that have been modified in the worktree or index # bsd doesn't have `-z` option for `comm` and `cut`, so use `tr` as work around prefix="$(git rev-parse --show-prefix) " - comm -23 <(git ls-tree -z -r --name-only --full-name @ | tr '\0' '\n') \ + comm -23 <(git ls-tree -z -r --name-only --full-name @ | tr '\0' '\n' | sort) \ <(git status -z --porcelain | tr '\0' '\n' | cut -c 4- | sort) \ | cut -c ${#prefix}- \ | tr '\n' '\0' \ diff --git a/check_dependencies.sh b/check_dependencies.sh index 6399510..05c2f73 100755 --- a/check_dependencies.sh +++ b/check_dependencies.sh @@ -6,5 +6,5 @@ err() { } if ! command -v column >/dev/null 2>&1; then - err "Need to install dependency 'column' before installation" + err "Need to install dependency 'column' before installation (can be found in bsdmainutils)" fi diff --git a/man/git-utimes.md b/man/git-utimes.md index e3ad079..9e9cf36 100644 --- a/man/git-utimes.md +++ b/man/git-utimes.md @@ -3,15 +3,15 @@ git-utimes(1) -- Change files modification time to their last commit date ## SYNOPSIS -`git-utimes` [-n, --newer] +`git-utimes` [--newer] ## DESCRIPTION - Change files modification time to their last commit date. Does not touch files that are in the working tree or index. + Change files modification time to their last commit date. Does not touch files that are in the working tree or index. ## OPTIONS - -n, --newer + --newer Preserves the original modification time of files that were committed from the local repo, by only touching files that are newer than their last commit date. @@ -23,11 +23,11 @@ git-utimes(1) -- Change files modification time to their last commit date * As above, but preserve original modification time of files that were committed from local repo: - $ git utimes -n + $ git utimes --newer ## AUTHOR -Written by Vitaly Chikunov <>, inspired by Stackexchange comments. Updated by Bill Wood to add --newer flag and ignore files in the working tree or index. +Written by Vitaly Chikunov <>, inspired by Stackexchange comments. Updated by Bill Wood <> to add `--newer` flag and ignore files in the working tree or index. ## REPORTING BUGS