Re: [PATCH v2] diff-lib.c: adjust position of i-t-a entries in diff
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 24, 2015, 17:00 UTC
- Message-ID
- <xmqqtwxa72kk.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CACsJy8BczCNxm3WHK1gtkXiZCbDkFD-67oOMR+eK8uwOBfQXuw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> "read-tree -m" does not invoke diff, does it? If I went with my > previous approach (modifying unpack-trees to ignore i-t-a entries) > then this could be a problem, but because unpack-trees is untouched, > merge operations should not be impacted by this patch.
Theoretically yes, but not quite.
I wouldn't be surprised if an enterprising soul saw an optimization opportunity in the "read-tree -m A B" codepath. When it finds that a tree in A and a valid cache-tree entry that corresponds to the tree matches, it could blow away all index entries covered by the cache-tree entry and replace them with B, either
(1) unconditionally when "-u" is not given; or
(2) as long as the working tree matches the index inside that
directory when running with "-u".And such an optimization used to be a valid thing to do in the old world; but (1) will break in the new world, if we drop that invalidation---the i-t-a entries will be discarded from the index.
As i-t-a is not a norm but an abberration, I'd rather keep the pessimizing invalidation to keep the door open for such an optimization for a more common case, and there may be other cases in which our correctness around i-t-a depends on.