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

Re: git-diff on touched files: bug or feature?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 2, 2007, 15:23 UTC
Message-ID
<Pine.LNX.4.64.0708021614420.14781@racer.site>
In-Reply-To
<46B1F3F4.5030504@midwinter.com>
Hi,
On Thu, 2 Aug 2007, Steven Grimm wrote:
Show 21 quoted lines
> Johannes Schindelin wrote:
> > This use case has not much to do with new users.  A new user _has_ to know
> > that updating all files, even if their content does not change, is not
> > right.
> >   
> 
> Someone who has used, say, Subversion might have a perfectly reasonable
> expectation that "git diff" will show differences in content, and when there
> are no differences in content, will not mention a file at all. Other version
> control systems have "diff" commands that ignore touched files.
> 
> I admit I also thought the empty diffs were a bug (albeit a minor one not
> worth making noise about) until this thread. Now I understand why it happens,
> though I still think we'd be better off just not displaying the filename in
> git-diff until we know there's an actual diff to display.
> 
> I certainly don't think the "it's a feature: it reminds you when you've edited
> a file without changing it" argument holds any water at all. If that were
> truly the intent, if we truly considered that to be useful information a
> developer would want to get at after the fact, then why would git-status throw
> away that information?

Okay, I'll answer just this one, instead of pointing you to the thread that I've been pointing to twice now (because your ideas about how git should work are usually similar to mine, and by way of saying thanks for your contributions):

When is the time to say "git status"?

It is just before committing. I.e when you really think that you're done editing, and want to have the end picture. "git status" only gives you names, and therefore it _has_ to update the index if it got out of sync, to show meaningful results.

When is the time to say "git diff"?

Much more often. In the middle of your work. And there it would be _disruptive_ if it updated the index all the time, especially if you have a quite large working tree.

But then, normal users do not touch all the files.  They don't.

So I doubt that in the common case the subject we are discussing matters at all.

Yes, "perl -pi" is something I used myself. Yes, I think it is a bug that it writes new files when it does not really change anything. And yes, I had a script lying somewhere on my backup hard disk which uses some evil "git diff --name-only | xargs bla" mantra (it does not even use the --quiet option, since that was not invented back then) to actually _undo_ the effects by setting the timestamps back, since the full compilation time in that project _hurt_.

But it is hardly an operation that I use daily. Hardly even twice a year.

Ciao, Dscho

Previous: Steven GrimmNext: Matthieu Moy
Message 13 of 75 in “git-diff on touched files: bug or feature?”
  1. Matthieu MoyAug 1, 2007
  2. Junio C HamanoAug 1, 2007
  3. Alexandre JulliardAug 1, 2007
  4. Junio C HamanoAug 1, 2007
  5. Alexandre JulliardAug 1, 2007
  6. Matthieu MoyAug 2, 2007
  7. Johannes SchindelinAug 2, 2007
  8. Matthieu MoyAug 2, 2007
  9. Johannes SchindelinAug 2, 2007
  10. Jean-François VeilletteAug 2, 2007
  11. Johannes SchindelinAug 2, 2007
  12. Steven GrimmAug 2, 2007
  13. Johannes SchindelinAug 2, 2007
  14. Matthieu MoyAug 2, 2007
  15. J. Bruce FieldsAug 2, 2007
  16. Add --show-touched option to show "diff --git" line when contents are unchangedSteven Grimm, Aug 3, 2007
  17. Junio C HamanoAug 3, 2007
  18. Johannes SchindelinAug 3, 2007
  19. Junio C HamanoAug 3, 2007
  20. Matthieu MoyAug 3, 2007
  21. Junio C HamanoAug 3, 2007
  22. Matthieu MoyAug 3, 2007
  23. Junio C HamanoAug 3, 2007
  24. Matthieu MoyAug 5, 2007
  25. Johannes SchindelinAug 5, 2007
  26. Matthieu MoyAug 5, 2007
  27. Matthias LederhoferAug 6, 2007
  28. David KastrupAug 6, 2007
  29. David KastrupAug 6, 2007
  30. Matthieu MoyAug 6, 2007
  31. Junio C HamanoAug 6, 2007
  32. David KastrupAug 7, 2007
  33. J. Bruce FieldsAug 7, 2007
  34. Linus TorvaldsAug 7, 2007
  35. Junio C HamanoAug 7, 2007
  36. David KastrupAug 7, 2007
  37. Linus TorvaldsAug 8, 2007
  38. Junio C HamanoAug 8, 2007
  39. Johannes SchindelinAug 8, 2007
  40. Junio C HamanoAug 8, 2007
  41. David KastrupAug 8, 2007
  42. Johannes SchindelinAug 8, 2007
  43. Jakub NarebskiAug 8, 2007
  44. Steven GrimmAug 7, 2007
  45. Add a note about the index being updated by git-status in some casesSteven Grimm, Aug 7, 2007
  46. git-diff: Output a warning about stale files in the indexSteven Grimm, Aug 7, 2007
  47. Junio C HamanoAug 7, 2007
  48. git-diff: Output a warning about stale files in the indexSteven Grimm, Aug 7, 2007
  49. Junio C HamanoAug 7, 2007
  50. Steven GrimmAug 7, 2007
  51. Jakub NarebskiAug 7, 2007
  52. Junio C HamanoAug 11, 2007
  53. Linus TorvaldsAug 8, 2007
  54. Steven GrimmAug 7, 2007
  55. Matthieu MoyAug 7, 2007
  56. Junio C HamanoAug 2, 2007
  57. Junio C HamanoAug 2, 2007
  58. Junio C HamanoAug 2, 2007
  59. Matthieu MoyAug 2, 2007
  60. Johannes SchindelinAug 2, 2007
  61. Junio C HamanoAug 2, 2007
  62. Jeff KingAug 3, 2007
  63. Junio C HamanoAug 3, 2007
  64. Jeff KingAug 3, 2007
  65. Junio C HamanoAug 3, 2007
  66. Shawn O. PearceAug 3, 2007
  67. Junio C HamanoAug 3, 2007
  68. Matthieu MoyAug 2, 2007
  69. Johannes SchindelinAug 2, 2007
  70. Matthieu MoyAug 2, 2007
  71. Johannes SchindelinAug 2, 2007
  72. Matthieu MoyAug 2, 2007
  73. Johannes SchindelinAug 2, 2007
  74. Joel ReedAug 2, 2007
  75. Johannes SchindelinAug 2, 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.