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

Re: How do get a specific version of a particular file?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 28, 2007, 00:54 UTC
Message-ID
<Pine.LNX.4.64.0702271643080.12485@woody.linux-foundation.org>
In-Reply-To
<7vejob9l70.fsf@assigned-by-dhcp.cox.net>
On Tue, 27 Feb 2007, Junio C Hamano wrote:
Show 6 quoted lines
> >
> > ... Negative object refs really don't make any sense unless you walk 
> > the object list (or you're "git diff" and know about ranges explicitly).
> 
> If you did not say "(or you're..." part, then I would agree
> to this 100%.
Well, I personally see (and think) of ".." as a "difference operator".
It very much is that, both for "git diff" and for "git log".
It's just that the "differences" are different.

In "git diff", the difference is obviously the code difference. When you say "git diff a..b" to "show the difference between a and b", you mean "show the patch". When you say "git log a..b", it's *still* a "difference", but now it's the *set* difference of the commits.

But "a..b" makes sense to me in both cases, exactly because to me, "a..b" _literally_ means "b - a" or "the difference between a and b".

Maybe I'm odd, or maybe it's because I have a fairly strong math background, but I have no trouble at all with a "difference operator" that does different things.

In real algebra (what in the US is apparently called "abstract algebra", and not to be confused with just "arithmetic with unknowns"), you do generalized arithmetic operations, and using "+" and "-" and "*" to mean arbitrary things that depend on the stuff you operate on, and doing different things depending on whether you talk about a "set of commits" (log) or talking about a "set of source code" (diff), makes total sense mathematically.

Show 23 quoted lines
> On the other hand, as you earlier said:
> 
>     On Fri, 22 Dec 2006,...
>     > 
>     > I can understand the advantage of a shortcut like "git diff ..next",
>     > ...
> 
>     I can't understand why people complain about this.
> 
>     YOU DON'T HAVE TO USE IT. 
>     ...
>     > But, really, I still don't understand exactly _what_ "diff a..b" even
>     > means. Can you explain it to me?
> 
>     It means exactly the same as "diff a b".
> 
>     It's that simple.
> 
> which made me lol, I am very tempted to say:
> 
> 	It means exactly the same as "show a b".
> 
>         It's that simple.

No, it really makes no sense at all if you see "a..b" as being a "difference operator".

What is the difference between two commits? It's either the difference in code (diff) _or_ it's the difference in sets of commits (log), and either is logical, but which one should "git show" actually show?

In NO CASE is it logical to say that "git show a..b" makes the "difference" be the "union" of two commits. That's just confusing and odd.

Show 6 quoted lines
> Back to serious my self, I am wondering if this is a sensible
> thing to ask:
> 
> 	$ git show master...maint
> 
> which your patch now forbids.
Again, what would that *mean*?

The "..." operator is the "symmetric difference". It has meaning both for code and for commit sets, but which one is "show"?

		Linus
Previous: Johannes SchindelinNext: Nicolas Pitre
Message 15 of 32 in “How do get a specific version of a particular file?”
  1. Theodore Ts'oFeb 27, 2007
  2. Christian MICHONFeb 27, 2007
  3. Peter BaumannFeb 27, 2007
  4. Alex RiesenFeb 27, 2007
  5. Alex RiesenFeb 27, 2007
  6. Johannes SchindelinFeb 27, 2007
  7. Theodore TsoFeb 27, 2007
  8. Johannes SchindelinFeb 27, 2007
  9. Theodore TsoFeb 27, 2007
  10. Randal L. SchwartzFeb 27, 2007
  11. Junio C HamanoFeb 27, 2007
  12. Linus TorvaldsFeb 28, 2007
  13. Junio C HamanoFeb 28, 2007
  14. Johannes SchindelinFeb 28, 2007
  15. Linus TorvaldsFeb 28, 2007
  16. Nicolas PitreFeb 28, 2007
  17. Linus TorvaldsFeb 28, 2007
  18. Nicolas PitreFeb 28, 2007
  19. Theodore TsoFeb 28, 2007
  20. Junio C HamanoFeb 28, 2007
  21. Theodore TsoFeb 28, 2007
  22. Junio C HamanoFeb 28, 2007
  23. Nicolas PitreFeb 28, 2007
  24. Johannes SchindelinFeb 28, 2007
  25. Linus TorvaldsFeb 28, 2007
  26. Junio C HamanoFeb 28, 2007
  27. Johannes SchindelinFeb 28, 2007
  28. Fix git-show man page formatting in the EXAMPLES sectionTheodore Tso, Feb 27, 2007
  29. Linus TorvaldsFeb 27, 2007
  30. Bill LearFeb 27, 2007
  31. Theodore TsoFeb 27, 2007
  32. Linus TorvaldsFeb 27, 2007

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.