git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] diff-lib.c: adjust position of i-t-a entries in diff

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 18, 2015, 12:47 UTC
Message-ID
<CACsJy8Beoz=qcHrOG=akCR+gOQRjBcsQHaXdL_=PW70BOf4q3g@mail.gmail.com>
In-Reply-To
<xmqq1tknpkwd.fsf@gitster.dls.corp.google.com>
On Wed, Mar 18, 2015 at 12:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 35 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> On Mon, Mar 16, 2015 at 09:05:45AM -0700, Junio C Hamano wrote:
>>> The offending one came from eec3e7e4 (cache-tree: invalidate i-t-a
>>> paths after generating trees, 2012-12-16), which was a fix to an
>>> earlier bug where a cache-tree written out of an index with i-t-a
>>> entries had incorrect information and still claimed it is fully
>>> valid after write-tree rebuilt it.  The test probably should add
>>> another path without i-t-a bit, run the same "diff --cached" with
>>> updated expectation before write-tre, and run the "diff --cached"
>>> again to make sure it produces a result that match the updated
>>> expectation.
>>
>> Would adding another non-i-t-a entry help? Before this patch
>> "diff --cached" after write-tree shows the i-t-a entry only when
>> eec3e7e4 is applied. But with this patch we don't show i-t-a entry any
>> more, before or after write-tree, eec3e7e4 makes no visible difference.
>>
>> We could even revert eec3e7e4 and the outcome of "diff --cached" would
>> be the same because we just sort of move the "invalidation" part from
>> cache-tree to do_oneway_diff(). Not invalidating would speed up "diff
>> --cached" when i-t-a entries are present. Still it may be a good idea
>> to invalidate i-t-a paths to be on the safe side. Perhaps a patch like
>> this to resurrect the test?
>
> My unerstanding of what eec3e7e4 (cache-tree: invalidate i-t-a paths
> after generating trees, 2012-12-16) fixed was that in this sequence:
>
>    ...
>
> So reverting the fix obviously is not the right thing to do.  If the
> tests show different results from two invocations of "diff --cached"
> with your patch applied, there is something that is broken by your
> patch, because the index and the HEAD does not change across
> write-tree in that test.

Right. I missed this but I think this is a less important test because I added a new test to make sure "diff --cached" ("git status" to be exact) outputs the right thing when i-t-a entries are present.

Show 8 quoted lines
> If on the other hand the tests show the same result from these two
> "diff --cached" and the result is different from what the test
> expects, that means your patch changed the world order, i.e. an
> i-t-a entry used to be treated as if it were adding an empty blob to
> the index but it is now treated as non-existent, then that is a good
> thing and the only thing we need to update is what the test expects.
> I am guessing that instead of expecting dir/bar to be shown, it now
> should expect no output?
Yes, no output.
> Does adding an non-i-t-a entry help?  It does not hurt, and it makes
> the test uses a non-empty output, making its effect more visible,
> which may or may not count as helping.

But still, if I revert the change in cache-tree.c and force write-tree to produce valid cache-tree when i-t-a entries are present, this test still passes incorrectly. This is why I changed the test.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 18 in “Bug fixes regarding diff and "git add -N"”
  1. 0/2 Bug fixes regarding diff and "git add -N"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  2. 1/2 diff --cached: do not report i-t-a entries as "new"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  3. Junio C HamanoMar 15, 2015
  4. diff-lib.c: adjust position of i-t-a entries in diffNguyễn Thái Ngọc Duy, Mar 16, 2015
  5. Michael J GruberMar 16, 2015
  6. Junio C HamanoMar 16, 2015
  7. Duy NguyenMar 17, 2015
  8. Junio C HamanoMar 17, 2015
  9. Duy NguyenMar 18, 2015
  10. Junio C HamanoMar 18, 2015
  11. Junio C HamanoMar 19, 2015
  12. Duy NguyenMar 24, 2015
  13. Junio C HamanoMar 24, 2015
  14. Junio C HamanoMar 23, 2015
  15. 2/2 diff-files: mark i-t-a paths as "new"Nguyễn Thái Ngọc Duy, Mar 9, 2015
  16. Junio C HamanoMar 15, 2015
  17. t2203,t4011: adjust to changed intent-to-add treatmentMichael J Gruber, Mar 9, 2015
  18. Junio C HamanoMar 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.