git-utimes: add --newer flag and don't touch files in the working tree and index
#969
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR adds a new flag,
-nor--newer, togit-utimes. This flag preserves the original modification date of files that originally were committed from the local repo, where the file may have been modified well before the commit date. The--newerflag causesgit-utimesto only touch files with a date that is newer than their commit date.Additionally, this PR addresses a few issues:
git-utimeswould change the date of files in the working tree and index to their commit date. This version doesn't touch files in the working tree and index, on the assumption that they are being worked on and the commit date is not relevant.git-utimeswould attempt to change the modification date on symbolic links. This was incorrectly changing the date on the linked file, not the symbolic link. This version correctly updates the link itself.git-utimeswas using the processor count to determine how many filesxargswould process on each command line (-nargument toxargs), which didn't seem to make much sense. This version passes 24 files on eachxargscommand line.git-utimeswas always touching files even if the modification date was the same as the commit date. After a pull, even files that were not modified by the pull would be touched. This version only touches files whose modification date is not the same as the commit date. This reports only updated files and makes it easier to understand which files have been changed by a pull.