guard against wrong timestamps in git log
authorJoey Hess <joeyh@joeyh.name>
Mon, 13 Nov 2023 19:06:04 +0000 (15:06 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 13 Nov 2023 19:06:04 +0000 (15:06 -0400)
For example, my sound repo has in the git-annex branch a commit from
2036, which is followed by one from 2034, in amoung commits from 2013.
Clearly there was a problem with the clock.

Since git log --date-order has a behavior of
"Show no parents before all of its children are shown", the data still
gets processed ok. The future timestamp just prevented displaying data
after that commit. It seems better, when the clock was wrong, to display
a wrong date, and then return to right dates.

It would be nice to filter out the wrong dates from display entirely,
but that seems it would need to buffer the whole output. This command is
too slow to buffer it all before displaying anything, and anyway this
kind of problem is probably rare.

Sponsored-by: Joshua Antonishen on Patreon
Command/Log.hs

index 0aea7dc7719c03f76136194c56a5f3d698651d54..78190f28fb23f0f7c318d8fa9df86fd581de790a 100644 (file)
@@ -408,6 +408,7 @@ sizeHistoryInfo mu o = do
                  && (prevoutput /= Just output) = do
                        displayts zone t output
                        return (zone, True, t, Just output)
+               | t < prevt = return (zone, displayedyet, t, Just output)
                | otherwise = return (zone, displayedyet, prevt, Just output)
          where
                output = intercalate "," (map showsize sizes)