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

Re: Summer of Code project ideas due this Friday

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2011, 20:54 UTC
Message-ID
<7vtyfa3ddm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110310192851.GB19257@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
>> I think the end-result would be a nice feature. I suspect that it would
>> not involve conversion from --cc, but more like using the difference
>> between the HEAD and the working tree, generated as if there is no
>> multi-stage index.
>
> The trouble is that I would like to see the combined diff, then say "OK"
> and have it apply the result to the index. But because we work on a
> per-hunk basis, you need to match the combined diff hunks to the regular
> diff hunks, taking into account that hunks could be split.  Which maybe
> is straightforward, but I haven't convinced myself yet that there are no
> corner cases where they don't line up.

Forgetting for now the implementation, I _think_ what you would want is for "git add -p" to notice that you are resolving conflicts, and do not bother you about cleanly merged parts (I take it is a given that you would always want to add them to the index without even inspecting when running "add -p"), and make the per-hunk selection loop ask only about the parts that originally had conflicts.

But it is rather hard to arrange. Neither "--cc" nor "-c" during the merge is about showing conflicts but is about showing the result with respect to the two originals. If you resolved conflicts in your editor already, there are no lines with "<<</>>>" markers that are different from either original to cause the "conflicted parts" to appear in their output. If your conflict resolution ended up in taking what one side did, "--cc" will hide it as a non-event. So at least you would be using "-c" to implement this.

Also, you have to remember that "add -p" is about adding the state you deem Ok incrementally to the index, that once you add a path to the index the higher stages for the path will collapse to stage #0, and that "-c" and "--cc" make their comparison based on what you have in higher stages.

I would imagine that a workable implementation might look like this:
 0. The solution introduces a new index extension, "PRSF" (partial
    resolution so far)".  This is a mapping from pathname to a blob object
    name.
 1. "git add -p" notices that you are in the middle of conflict
    resolution, by noticing that you have higher stages to the path.
 2. Look up the path from the PRSF extension.  If there is no entry for
    the path, recreate the content-level 3-way merge using the content of
    three stages (i.e. the state immediately after the mergy operation
    that caused the conflicts before you touched the corresponding file in
    your working tree), and register this image (with the full glory of
    "<<</>>>" conflict markers) to the extension.  If there already is an
    entry in the extension for the path, skip this step.
 3. The patch the user will see in the interactive hunk selection is the
    difference between the working tree and the PRSF image, not your
    regular index (nor the HEAD version). This allows you to see how you
    resolved the conflict incrementally so far.
 4. Choosing a hunk to "apply" would not affect the index entry for the
    path, as it would collapse its higher stages.  It instead updates the
    blob registered in the PRSF extension using the hunk you are applying.

If you are running "git add -p" incrementally (i.e. edit a little, review with diff, then "add -p" the part you are sure about, and repeat the whole thing), the next invocation of "git add -p" would notice that you still have unresolved conflicts in PRSF. It will skip the step 2 above and the step 3 will let you review the remaining difference between the PRSF image (which you updated in step 4 during the last round) and what you have in the working tree. The step 4 will update the PRSF image for the next invocation of "git add -p". And you continue until you are done.

At the end (we would probably need a good way to detect the user might want to declare "end" automatically for a good user experience), use the PRSF image to collapse the higher stages for the path down to stage 0.

Previous: Jeff KingNext: Jeff King
Message 21 of 63 in “Google Summer of Code 2011”
  1. Shawn PearceMar 3, 2011
  2. Jeff KingMar 3, 2011
  3. Shawn PearceMar 3, 2011
  4. Jeff KingMar 3, 2011
  5. Jakub NarebskiMar 3, 2011
  6. Jeff KingMar 9, 2011
  7. Jeff KingMar 9, 2011
  8. Shawn PearceMar 9, 2011
  9. Jeff KingMar 9, 2011
  10. Shawn PearceMar 9, 2011
  11. Summer of Code project ideas due this FridayJeff King, Mar 9, 2011
  12. Jonathan NiederMar 10, 2011
  13. Jeff KingMar 10, 2011
  14. Shawn PearceMar 10, 2011
  15. Alexander MiselerMar 10, 2011
  16. Thomas RastMar 10, 2011
  17. Santi BéjarMar 10, 2011
  18. Jeff KingMar 10, 2011
  19. Junio C HamanoMar 10, 2011
  20. Jeff KingMar 10, 2011
  21. Junio C HamanoMar 10, 2011
  22. Jeff KingMar 10, 2011
  23. Junio C HamanoMar 10, 2011
  24. Jeff KingMar 10, 2011
  25. Thomas RastMar 11, 2011
  26. Jakub NarebskiMar 10, 2011
  27. Thomas RastMar 11, 2011
  28. History surgery with fast-import (Re: Summer of Code project ideas due this Friday)Jonathan Nieder, Mar 12, 2011
  29. Ramkumar RamachandraMar 13, 2011
  30. Nguyen Thai Ngoc DuyMar 10, 2011
  31. Jeff KingMar 10, 2011
  32. Alexander MiselerMar 10, 2011
  33. Jeff KingMar 10, 2011
  34. Alexander MiselerMar 11, 2011
  35. Alexander MiselerMar 12, 2011
  36. Alexander MiselerMar 11, 2011
  37. Ilari LiusvaaraMar 11, 2011
  38. Nguyen Thai Ngoc DuyMar 11, 2011
  39. Alexander MiselerMar 11, 2011
  40. Nguyen Thai Ngoc DuyMar 11, 2011
  41. Sam VilainMar 11, 2011
  42. Alexander MiselerMar 12, 2011
  43. Ævar Arnfjörð BjarmasonMar 11, 2011
  44. code.sculptor@gmail.comMar 11, 2011
  45. Jakub NarebskiMar 17, 2011
  46. Heiko VoigtMar 22, 2011
  47. J.H.Mar 22, 2011
  48. Pat ThoytsMar 25, 2011
  49. Jakub NarebskiMar 25, 2011
  50. Ramkumar RamachandraMar 3, 2011
  51. Jonathan NiederMar 3, 2011
  52. Sverre RabbelierMar 7, 2011
  53. Ramkumar RamachandraMar 8, 2011
  54. Sverre RabbelierMar 8, 2011
  55. Jens LehmannMar 3, 2011
  56. Christian CouderMar 5, 2011
  57. Sam VilainMar 6, 2011
  58. Heiko VoigtMar 7, 2011
  59. Fredrik GustafssonMar 7, 2011
  60. Heiko VoigtMar 9, 2011
  61. Fredrik GustafssonMar 9, 2011
  62. Heiko VoigtMar 10, 2011
  63. Thomas RastMar 9, 2011

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.