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

Re: diff machinery cleanup

From
Junio C Hamano <junkio@cox.net>
Date
Aug 10, 2006, 09:36 UTC
Message-ID
<7vejvpvsni.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060810082455.GA30739@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
> It seems clear that there's some global magic touched by the first diff
> that impacts the second. I have to give up on finding it for tonight,
> but I'm hoping somebody who knows more about the code will find it
> obvious (or can tell me that I'm doing something else horribly wrong in
> the above, or that these functions were never intended to be called
> within the same program).
In general, run_diff_X are _not_ designed to run twice.

The run_diff_index() function munges the index while doing its work (e.g. mark_merge_entries() hoists unmerged entries to stage 3 -- and worse yet creating duplicate entries for the same path at stage 3; read_tree() reads the entries into stage 1 so that it can be compared in-index with stage 0 entries). The other function, run_diff_files() have the same assumption but does not touch index if I recall correctly.

If you are working in "next" branch where Johannes's merge-recur work introduced discard_cache(), you could fake this somehow stashing away a copy of the original index, and once you are done with run_diff_index(), clean the slate by calling discard_cache() once you are done, and swap the original index in before running run_diff_files().

To solve this cleanly without doing the index munging hack, you would (actually, I would) need to have a new path walker that walks index, tree and working tree in parallel, which I was working on in the git-status/git-commit rewrite I started and discarded a few days ago.

Previous: Jeff KingNext: Jeff King
Message 2 of 6 in “diff machinery cleanup”
  1. Jeff KingAug 10, 2006
  2. Junio C HamanoAug 10, 2006
  3. Jeff KingAug 10, 2006
  4. Junio C HamanoAug 10, 2006
  5. Jeff KingAug 10, 2006
  6. Junio C HamanoAug 10, 2006

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.