`git-utimes`: add --newer flag and don't touch files in the working tree and index by wpwoodjr · Pull Request #969 · tj/git-extras

The PR adds a new flag, -n or --newer, to git-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 --newer flag causes git-utimes to only touch files with a date that is newer than their commit date.

Additionally, this PR addresses a few issues:

  1. git-utimes would 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.
  2. git-utimes would 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.
  3. git-utimes was using the processor count to determine how many files xargs would process on each command line (-n argument to xargs), which didn't seem to make much sense. This version passes 24 files on each xargs command line.
  4. git-utimes was 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.