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

Re: CFT: merge-recursive in C

From
Junio C Hamano <junkio@cox.net>
Date
Jun 27, 2006, 00:25 UTC
Message-ID
<7v4py7h2b9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060626233838.GA3121@steel.home>
fork0@t-online.de (Alex Riesen) writes:
Show 5 quoted lines
> To my deep disappointment, it didn't work out as good as I hoped: one
> program I see most often and for longest time in the process list
> (git-diff-tree) is a too complex thing to be put directly into
> merge-recursive.c, so any help in this direction will be greatly
> appreciated.

Actually, diff-tree is (and to similar degree the internal diff machinery is) quite reusable as library piece, far more reusable than other parts of the core git. If you present what you want to achieve nicely and ask politely I might even get conned into helping you interface with the rest of your code ;-).

I am guessing that you want to find out how to do the diff-tree -M used by the recursive merge without spitting out patch text nor raw output. That's quite doable and should be easy. Most likely you would use NO_OUTPUT option when you call diff_tree().

First look at builtin-diff.c::builtin_diff_tree() to see how you can call the diff machinery given two tree object names. diff_tree() itself does not emit the diff, but leaves the result in "diff queue".

After calling diff_tree(), inspect diff_queued_diff() and use the result to do whatever sensible. The queue is an array of diff_filepair that records the (path, sha1, mode) among other things from old tree and from new tree (the one from the old tree is called "one", and the new tree is called "two").

So if you have one->path = "old-name.c" and two->path = "new-name.c" then you see the old-name.c file was renamed to new-name.c

When you are done, do not forget to call diff_flush() to get rid of queued_diff(); otherwise you would leak.

Have fun.
Previous: Alex RiesenNext: Alex Riesen
Message 8 of 27 in “CFT: merge-recursive in C”
  1. Alex RiesenJun 26, 2006
  2. CFT: merge-recursive in C (test updates)Alex Riesen, Jun 26, 2006
  3. Linus TorvaldsJun 26, 2006
  4. Linus TorvaldsJun 27, 2006
  5. Alex RiesenJun 27, 2006
  6. Junio C HamanoJun 27, 2006
  7. Alex RiesenJun 27, 2006
  8. Junio C HamanoJun 27, 2006
  9. Alex RiesenJun 27, 2006
  10. Notes on diffcore APIJunio C Hamano, Jun 27, 2006
  11. Alex RiesenJun 27, 2006
  12. Junio C HamanoJun 27, 2006
  13. Johannes SchindelinJun 28, 2006
  14. Johannes SchindelinJun 27, 2006
  15. Alex RiesenJun 27, 2006
  16. Johannes SchindelinJun 27, 2006
  17. Alex RiesenJun 27, 2006
  18. Junio C HamanoJun 27, 2006
  19. Alex RiesenJun 27, 2006
  20. Johannes SchindelinJun 27, 2006
  21. Alex RiesenJun 27, 2006
  22. Uwe ZeisbergerJun 28, 2006
  23. Alex RiesenJun 28, 2006
  24. Junio C HamanoJun 28, 2006
  25. Christopher FaylorJun 28, 2006
  26. Alex RiesenJun 29, 2006
  27. Christopher FaylorJun 29, 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.