Re: Git commit generation numbers
From: Jeff King <hidden>
Date: 2016-06-15 22:51:36
On Sat, Jul 16, 2011 at 11:16:45AM +0200, Christian Couder wrote:
If "git tag --contains" and "git branch --contains" give incorrect answers because the commiter date is wrong in some commits, then why not use "git replace" to "change" the commiter date in the commits that have a wrong date? Is it because you don't want to use "git replace", or because there is no script to do it automatically, or is there another reason?
That would work. There are a few tricky things, though:
1. Most commits have less than 100 skewed commits. But some have many
(e.g., thousands in the mesa repo). How well does git cope with
large numbers of replace refs, performance-wise?
2. Declaring which commits are skewed is actually tricky. You can find
a commit whose timestamp is less than the timestamp of one of its
ancestors. But you don't know whether it is skewed, or the
ancestor.
If you are implementing a list of commits whose timestamps
shouldn't be used for traversal cutoff, it doesn't really matter
who is _right_; you just care about whether the timestamps are
strictly increasing from that point.
But once you start replacing commits, you need to put in a
reasonable value for the timestamp. So you may well be replacing a
perfectly valid commit with one that has bogus, skewed information
in the commit timestamp.
3. Any value you put in is actually going to be a lie during things
like "git log --pretty=raw". That may be OK. But it is letting an
optimization meant to make traversal fast and accurate bleed into
the actual data we show the user.
4. Sometimes we need to do traversals on the real objects (e.g.,
because we are doing upload-pack). To get the benefit, those
traversals would presumably need to look at both the original
object and the replacement, use the timestamp from the replacement
for traversal, but otherwise use the original object.
-Peff