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

Re: [BUG] Highly inconsistent diff UI

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 24, 2013, 18:11 UTC
Message-ID
<7v38ufer2x.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALkWK0mVDT5ESnVJAWQ83gQnmxmGDoM_Y0nE4FGybcjcenA_KA@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> What are your thoughts on inventing a new syntax A~B = $(git
> merge-base A B) B which can be used by both range commands like log
> and non-range commands like diff ?  (In other words, why shouldn't log
> be able to do this?).

The idea for a new syntax to denote a merge base may be an interesting one.

"log" is inherently about ranges, so you do not need a new operator to denote a merge base. Between "log A..B" and "log A...B" with or without --left-right, --left-only and --right-only, you should be able to ask questions about histories leading to commit A and B without having to worry about a single "merge base" between A and B, no? So I do not think "A~B" would help "log".

Because "diff" is inherently about endpoints, you DO have to have a single "merge base" that gives you a point to compare something else against.

The reason why "diff A...B" was invented was primarily because we wanted to avoid having to say A twice on the command line, be it "diff $(git merge-base A B) B" or "diff A~B B". In other words, "A~B" will not help "diff" at all, either [*1*].

There isn't always a single merge base between an arbitrary pair of commits (there may be 0, or 2 or more). When used in the context of "diff A...B", we know that the user is more interested in using one merge base (among possibly many) to get some diff, than seeing the command fail [*2*]. Taking that as a context cue, "diff A...B" can (and did) choose to use one picked at random, even though the design is fully aware that the chosen one may not be the best one.

A generic "A~B" syntax implemented at the revision parser level may not have that luxury of assuming that it is fine to pick any, and may have to fail when there is not a unique merge-base.

[Footnote]
*1* That does not mean nobody needs that syntax.  It just means that
    it is still a solution looking for a problem.
*2* Otherwise the user can more carefully script what he wants to do
    using the merge-base command himself, choosing to do different
    things when there are 0, or 2 or more merge bases.
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 10 of 45 in “[BUG] Highly inconsistent diff UI”
  1. Ramkumar RamachandraApr 24, 2013
  2. Jonathan NiederApr 24, 2013
  3. Junio C HamanoApr 24, 2013
  4. Ramkumar RamachandraApr 24, 2013
  5. Jonathan NiederApr 24, 2013
  6. Junio C HamanoApr 24, 2013
  7. Ramkumar RamachandraApr 24, 2013
  8. Junio C HamanoApr 24, 2013
  9. Ramkumar RamachandraApr 24, 2013
  10. Junio C HamanoApr 24, 2013
  11. Ramkumar RamachandraApr 24, 2013
  12. Ramkumar RamachandraApr 24, 2013
  13. Junio C HamanoApr 24, 2013
  14. Ramkumar RamachandraApr 24, 2013
  15. Junio C HamanoApr 24, 2013
  16. Ramkumar RamachandraApr 24, 2013
  17. Thomas RastApr 24, 2013
  18. Ramkumar RamachandraApr 24, 2013
  19. Jonathan NiederApr 24, 2013
  20. Ramkumar RamachandraApr 24, 2013
  21. Thomas RastApr 25, 2013
  22. Ramkumar RamachandraApr 25, 2013
  23. Junio C HamanoApr 25, 2013
  24. Ramkumar RamachandraApr 25, 2013
  25. Jonathan NiederApr 25, 2013
  26. Junio C HamanoApr 25, 2013
  27. Duy NguyenApr 26, 2013
  28. Phil HordApr 24, 2013
  29. Junio C HamanoApr 24, 2013
  30. Ramkumar RamachandraApr 24, 2013
  31. Ramkumar RamachandraApr 24, 2013
  32. Junio C HamanoApr 25, 2013
  33. Ramkumar RamachandraApr 25, 2013
  34. Ramkumar RamachandraApr 25, 2013
  35. Ramkumar RamachandraApr 26, 2013
  36. Ramkumar RamachandraApr 26, 2013
  37. Junio C HamanoApr 29, 2013
  38. Ramkumar RamachandraApr 29, 2013
  39. Junio C HamanoApr 29, 2013
  40. Ramkumar RamachandraApr 29, 2013
  41. Ramkumar RamachandraApr 29, 2013
  42. Junio C HamanoApr 29, 2013
  43. Ramkumar RamachandraApr 29, 2013
  44. John KeepingApr 29, 2013
  45. Ramkumar RamachandraApr 25, 2013

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.