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

Re: [PATCH 2/5] diff --quiet

From
Junio C Hamano <junkio@cox.net>
Date
Mar 16, 2007, 00:16 UTC
Message-ID
<7v3b4611rk.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0703152211050.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> The point I tried to make: without "-w" or "-b", you can compare at the 
> tree level. No need for a --quiet option.

That's not true. The --quiet option is not about comparing at the tree level vs looking inside the blobs. It helps to optimize the tree level comparison as well. The difference Linus was happy about comes from exactly the early exit from tree comparison.

The current --quiet will report if they are different at the tree level and does not take filtering done at the later phases into account at all, and that is a conscious design decision so that we can use it for optimizing try_to_simplify_commit(). So for example, if you have any change that a plain "git diff-*" says there are differences, the option reports there indeed are differences, like this:

	$ git reset --hard ;# start from the clean state
        $ touch Makefile
        $ git diff-files -p
        diff --git a/Makefile b/Makefile
        $ git diff-files --quiet; echo $?
	1

I didn't consider -w nor -b when I made the design decision that leads to the above behaviour, but I think the filtering done at the textual patch generation phase falls into the same category. If you do the following, the answer would be "they are different":

	$ sed -e 's/$/ /' <Makefile >Makefile+
        $ cat Makefile+ >Makefile
        $ rm Makefile+
        $ git update-index --refresh
        $ git diff-files -b -p
        diff --git a/Makefile b/Makefile
        index dc024d4..1c328be 100644
        $ git diff-files -b -p --quiet; echo $?
        1

Options like -w and -b are only about not showing the lines; you still get the diff header that reports they are different. So in that sense the output from the last command above is correct.

I am however wondering if we want to have (and if it would be worth the trouble to add) an option to have the command say if there will be textual difference output without producing it. I do not see much value in it right now, but it might turn out to be handy. I do suspect that would be a rather intrusive and error prone change, though.

A good news is that such an option needs to work at a different level than the existing --quiet, which works in diffcore_std(). The new option would probably need to work inside diff_flush() which is a later phase. So no matter how you screw up, it would hopefully not break revision traversal too much.

We might want to rename the existing one --quick and name that new option --quiet, though, if we go that route.

Previous: Johannes SchindelinNext: Junio C Hamano
Message 20 of 23 in “diff --quick”
  1. 1/2 diff --quickJunio C Hamano, Mar 14, 2007
  2. 1/5 Remove unused diffcore_std_no_resolveJunio C Hamano, Mar 14, 2007
  3. 2/5 diff --quietJunio C Hamano, Mar 14, 2007
  4. Alex RiesenMar 14, 2007
  5. Alex RiesenMar 14, 2007
  6. Junio C HamanoMar 14, 2007
  7. Alex RiesenMar 15, 2007
  8. Alex RiesenMar 14, 2007
  9. Junio C HamanoMar 14, 2007
  10. Linus TorvaldsMar 15, 2007
  11. Junio C HamanoMar 15, 2007
  12. Junio C HamanoMar 15, 2007
  13. Linus TorvaldsMar 15, 2007
  14. Alex RiesenMar 15, 2007
  15. Johannes SchindelinMar 15, 2007
  16. Alex RiesenMar 15, 2007
  17. Johannes SchindelinMar 15, 2007
  18. Alex RiesenMar 15, 2007
  19. Johannes SchindelinMar 15, 2007
  20. Junio C HamanoMar 16, 2007
  21. 3/5 Teach --quiet to diff backends.Junio C Hamano, Mar 14, 2007
  22. 4/5 revision.c: explain what tree_difference doesJunio C Hamano, Mar 14, 2007
  23. 5/5 try-to-simplify-commit: use diff-tree --quiet machinery.Junio C Hamano, Mar 14, 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.