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

Re: [Bug report] git diff stat shows unrelated diff

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2019, 22:10 UTC
Message-ID
<xmqqmumy6mxe.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CABPp-BGstumw1eyZ++0itk-AR0Bk5zd0AchgznBpMq35a6ScUg@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 5 quoted lines
> The only thing I seem to be able to retain is the following:  "git
> diff D..E is totally useless and should be an error because (1) it
> doesn't do what I expect and (2) for folks that want the behavior
> currently gotten with that syntax can instead just use a space instead
> of a double dot."

That sums up pretty nicely. diff is fundamentally an operation between two endpoints, so the range notation a..b does not work nicely with it at the conceptual level.

When we realized that we can take advantage of the above fact, and reuse a range notation to mean something that is generally useful in the context of diff, such as 'one end of the comparison is the merge base between a and b, and the other end is b', it was too late to use "a..b", as an early adopters of Git was already used to the fact that "a..b" happened to mean the same thing as "comparison of one end is a, the other end is b", pretty much implemented without much thought.

It might be _possible_ to spend a year (i.e. 4 cycles) to start warning when two-dot notation is used for "git diff" (only, not any plumbing like "git diff-files") and tell the user to use the more logical two-end notation "git diff A B" and then eventually error out when two-dot notation is used, while retaining the three-dot notation throughout and to the eternity. I am not sure if it is worth the deprecation cost, though.

Previous: Elijah NewrenNext: Denton Liu
Message 4 of 17 in “[Bug report] git diff stat shows unrelated diff”
  1. Viresh KumarFeb 14, 2019
  2. Johannes SixtFeb 14, 2019
  3. Elijah NewrenFeb 14, 2019
  4. Junio C HamanoFeb 14, 2019
  5. Denton LiuFeb 15, 2019
  6. Elijah NewrenFeb 15, 2019
  7. Junio C HamanoFeb 15, 2019
  8. Philip OakleyFeb 15, 2019
  9. Junio C HamanoFeb 15, 2019
  10. Philip OakleyFeb 16, 2019
  11. Junio C HamanoFeb 17, 2019
  12. Philip OakleyFeb 17, 2019
  13. Junio C HamanoFeb 18, 2019
  14. Junio C HamanoFeb 15, 2019
  15. Viresh KumarFeb 15, 2019
  16. Elijah NewrenFeb 15, 2019
  17. Viresh KumarFeb 18, 2019

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.