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

Re: [PATCH] Re-re-re-fix common tail optimization

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 17, 2007, 10:59 UTC
Message-ID
<36E62F9B-26FF-4DC0-99B8-D6DC2B960E67@wincent.com>
In-Reply-To
<Pine.LNX.4.64.0712171038130.9446@racer.site>
El 17/12/2007, a las 11:39, Johannes Schindelin escribió:
Show 29 quoted lines
> Hi,
>
> On Mon, 17 Dec 2007, Wincent Colaiuta wrote:
>
>> El 16/12/2007, a las 23:29, Jeff King escribi?:
>>
>>> On Sun, Dec 16, 2007 at 02:23:27PM -0800, Junio C Hamano wrote:
>>>
>>>>> Aren't we using "git diff" for the second diff there nowadays?
>>>>
>>>> Some people seem to think that is a good idea, but I generally do
>>>> not like using "git diff" between expect and actual (both  
>>>> untracked)
>>>> inside tests.  The last "diff" is about validating what git does  
>>>> and
>>>> using "git diff" there would make the test meaningless when "git
>>>> diff" itself is broken.
>>>
>>> I think that is a valid concern. But ISTR that were some issues with
>>> using GNU diff. Commit 5bd74506 mentions getting rid of the  
>>> dependency
>>> in all existing tests, but gives no reason.
>>
>> I'd say it's safe and sensible to use "git diff" in all tests  
>> *except*
>> for tests of "git diff" itself.
>
> To the contrary.  It has to test "git diff", so it must use "git  
> diff".
Obviously, you can only test "git diff" by actually running it.
Show 7 quoted lines
> As for the reference output: we include the expected diffs as texts,  
> and
> therefore do not really have to rely on having GNU diff installed.
>
> Besides, we cannot even test the goodies like "rename from" by  
> comparing
> to GNU diff's output.

Sorry, I didn't make myself clear. That's not what I was proposing at all. I was talking about this kind of example:

> +	git diff -U0 | sed -e "/^index/d" -e "s/$z2047/Z/g" >actual &&
> +	diff -u expect actual

First line uses "git diff", if the second line uses "git diff" as well and "git diff" happens to be broken then you're using a broken tool to test a broken tool, as Junio already pointed out. I presumed that if you had read the whole thread then that would be obvious (look at the quoted section from Junio above).

In the example you're not interested in the details of the output format, only in the exit status, so it is appropriate to use diff instead of "git diff".

Wincent
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 16 of 30 in “trim_common_tail bug?”
  1. Jeff KingDec 15, 2007
  2. Jeff KingDec 15, 2007
  3. Junio C HamanoDec 15, 2007
  4. Jeff KingDec 15, 2007
  5. Jeff KingDec 16, 2007
  6. Junio C HamanoDec 16, 2007
  7. Junio C HamanoDec 16, 2007
  8. Jeff KingDec 16, 2007
  9. Re-re-re-fix common tail optimizationJunio C Hamano, Dec 16, 2007
  10. Jeff KingDec 16, 2007
  11. Junio C HamanoDec 16, 2007
  12. Junio C HamanoDec 16, 2007
  13. Jeff KingDec 16, 2007
  14. Wincent ColaiutaDec 17, 2007
  15. Johannes SchindelinDec 17, 2007
  16. Wincent ColaiutaDec 17, 2007
  17. Johannes SchindelinDec 17, 2007
  18. Wincent ColaiutaDec 17, 2007
  19. Jeff KingDec 17, 2007
  20. Johannes SixtDec 17, 2007
  21. Johannes SchindelinDec 17, 2007
  22. Junio C HamanoDec 17, 2007
  23. Johannes SchindelinDec 17, 2007
  24. Charles BaileyDec 19, 2007
  25. Jeff KingDec 19, 2007
  26. Charles BaileyDec 19, 2007
  27. Junio C HamanoDec 20, 2007
  28. Wincent ColaiutaDec 20, 2007
  29. Charles BaileyDec 20, 2007
  30. Junio C HamanoDec 20, 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.