-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #882 from vt-alt/git-utimes
git-utimes: Change files modification time to their last commit date
- Loading branch information
Showing
8 changed files
with
239 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Change files modification time to their last commit date | ||
# | ||
|
||
if [ "$1" = --touch ]; then | ||
# Internal use option only just to parallelize things. | ||
shift | ||
for f; do | ||
t=$(git --no-pager log --no-renames --pretty=format:%cI -1 @ -- "$f" 2>/dev/null) | ||
if [ -n "$t" ]; then | ||
echo "+ touch -d $t $f" >&2 | ||
touch -d "$t" "$f" | ||
fi | ||
done | ||
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) | ||
git ls-tree -z -r -t --name-only @ \ | ||
| xargs -0 -P${NPROC:-1} -n${NPROC:-1} -r git utimes --touch | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.\" generated with Ronn/v0.7.3 | ||
.\" http://github.com/rtomayko/ronn/tree/0.7.3 | ||
. | ||
.TH "GIT\-UTIMES" "1" "September 2020" "" "Git Extras" | ||
. | ||
.SH "NAME" | ||
\fBgit\-utimes\fR \- Change files modification time to their last commit date | ||
. | ||
.SH "SYNOPSIS" | ||
\fBgit\-utimes\fR | ||
. | ||
.SH "DESCRIPTION" | ||
Change files modification time to their last commit date\. | ||
. | ||
.SH "OPTIONS" | ||
No options needed\. | ||
. | ||
.SH "EXAMPLES" | ||
git utimes | ||
. | ||
.SH "AUTHOR" | ||
Written by Vitaly Chikunov <\fIvt@altlinux\.org\fR>, inspired by Stackexchange comments\. | ||
. | ||
.SH "REPORTING BUGS" | ||
<\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
. | ||
.SH "SEE ALSO" | ||
<\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
git-utimes(1) -- Change files modification time to their last commit date | ||
========================================================================= | ||
|
||
## SYNOPSIS | ||
|
||
`git-utimes` | ||
|
||
## DESCRIPTION | ||
|
||
Change files modification time to their last commit date. | ||
|
||
## OPTIONS | ||
|
||
No options needed. | ||
|
||
## EXAMPLES | ||
|
||
git utimes | ||
|
||
## AUTHOR | ||
|
||
Written by Vitaly Chikunov <<[email protected]>>, inspired by Stackexchange comments. | ||
|
||
## REPORTING BUGS | ||
|
||
<<https://github.com/tj/git-extras/issues>> | ||
|
||
## SEE ALSO | ||
|
||
<<https://github.com/tj/git-extras>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters