Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update git-utimes.{1,html} to add --newer flag #972

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions bin/git-utimes
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ "$1" = "--touch" ]; then
git_s=$(git --no-pager log --no-renames --pretty=format:%ct -1 @ -- "$f" 2>/dev/null)
mod_s=$(stat $stat_flags "$f" 2>/dev/null)
if [ -n "$git_s" ] && [ -n "$mod_s" ] && [ "$mod_s" -ne "$git_s" ]; then
if [ "$mod_s" -gt "$git_s" ] || [ ! -n "$newer_flag" ]; then
if [ "$mod_s" -gt "$git_s" ] || [ -z "$newer_flag" ]; then
t=$(date $date_flags$git_s '+%Y%m%d%H%M.%S')
echo "+ touch -h -t $t $f" >&2
touch -h -t "$t" "$f"
Expand All @@ -32,7 +32,6 @@ else
# `-n` should be limited or parallelization will not give effect,
# because all args will go into single worker.
NPROC=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
# shellcheck disable=SC2086
# 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) "
Expand Down
39 changes: 22 additions & 17 deletions man/git-utimes.1
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-UTIMES" "1" "September 2020" "" "Git Extras"
.
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-UTIMES" "1" "May 2022" "" "Git Extras"
.SH "NAME"
\fBgit\-utimes\fR \- Change files modification time to their last commit date
.
.SH "SYNOPSIS"
\fBgit\-utimes\fR
.
\fBgit\-utimes\fR [\-\-newer]
.SH "DESCRIPTION"
Change files modification time to their last commit date\.
.
Change files modification time to their last commit date\. Does not touch files that are in the working tree or index\.
.SH "OPTIONS"
No options needed\.
.
\-\-newer
.P
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\.
.SH "EXAMPLES"
git utimes
.
Update all files' modification time to their last commit date, except those in working tree or index:
.IP "" 4
.nf
$ git utimes
.fi
.IP "" 0
.P
As above, but preserve original modification time of files that were committed from local repo:
.IP "" 4
.nf
$ git utimes \-\-newer
.fi
.IP "" 0
.SH "AUTHOR"
Written by Vitaly Chikunov <\fIvt@altlinux\.org\fR>, inspired by Stackexchange comments\.
.
Written by Vitaly Chikunov <\fIvt@altlinux\.org\fR>, inspired by Stackexchange comments\. Updated by Bill Wood <\fIwpwoodjr@gmail\.com\fR> to add \fB\-\-newer\fR flag and ignore files in the working tree or index\.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
32 changes: 21 additions & 11 deletions man/git-utimes.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/git-utimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ git-utimes(1) -- Change files modification time to their last commit date

## EXAMPLES

* Update all files' modification time to their last commit date, except those in working tree or index:
Update all files' modification time to their last commit date, except those in working tree or index:

$ git utimes

* As above, but preserve original modification time of files that were committed from local repo:
As above, but preserve original modification time of files that were committed from local repo:

$ git utimes --newer

Expand Down