Reputation: 26005
This is most useful for directories containing latex compilation files. Sometimes I may re-compile a file with an updated image (so tex is identical), and the resulting log is identical to the previous with a date change.
I would prefer if GIT not show these in the status at all (behavior can be anything instead - auto checkout the original for example every git status
).
Specifically the current diff is (the difference is the date at the end):
-This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2017.5.16) 8 OCT 2017 17:01
+This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2017.5.16) 22 NOV 2017 11:26
Note Make git ignore modification date changes if the content of the file stays the same (or similar) is irrelevant to this question, I'm not talking about modification time which GIT ignores.
Is it possible through some git scripting to prevent these types of changes from appearing in git status?
The answer should probably be more general than my specific example (any content that needs ignoring), if possible of course. Answers could hide it somehow (not ignore permanently in case of a real change) or checkout previous version on status or anything else achieving this result.
Upvotes: 4
Views: 1556
Reputation: 1329890
This is a job for a git content filter driver, as I illustrated in "Can git ignore a specific line?".
In your case, the:
smudge
script would (only for latex file in compilation folder) detect the date, and save it into a private ignored file named after the latex file being parsed.git checkout
clear
script would read the private ignored file content to retrieve the original date, and replace (sed) the changed date by the one read in the temp file.git commit
, or even git diff
, ensuring git ignores those kind of differences! A content filter driver is the way to ignore specific changes of a file.
Upvotes: 4