restore-mtime: Improve behavior of --first-parent #69
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.
Previously this flag was just passed to git whatchanged, but that doesn't seem to affect what files are listed on the merge commits. This uses --diff-merges=first-parent when both --merge and --first-parent are set. This way only files that are different from the first parent will get an updated timestamp.
This seems to align with the original goal of #21. Maybe there's a usecase I'm not thinking of where still using the full set of changed files from the merge commit makes sense. In that case I could also make this a separate option.
Our usecase is using the timestamps for rsync. For that case this is an improvement over just
-m
because it triggers less unnecessary timestamp changes (as long as the merges are in the right direction).I'm not sure if the
elif
makes sense since when not evaluating merge commits it will just lead to changes coming from merges to be missed entirely.--diff-merges
seems to have been introduced in git 2.31 (I'm a bit confused because the release notes for 2.32 list it as well) so maybe the version in the README would have to be updated?