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

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

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Aug 2, 2007, 09:23 UTC
Message-ID
<vpqhcni47ek.fsf@bauges.imag.fr>
In-Reply-To
<7v4pjj5fp6.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <gitster@pobox.com> writes:
Show 21 quoted lines
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> $ touch bar
>> $ git diff
>> diff --git a/bar b/bar         <--- here ---<
>> $ git status
>> # On branch master
>> nothing to commit (working directory clean)
>> $ git diff                     <--- status updated
>>                                     the stat in the index.
>>
>> Is this intended,
>
> Yes.  Very much so, intentionally, from very early days of git.
> This serves as a reminder to the user that he started editing
> but changed his mind to end up with the same contents as the
> original, until the next "update-index --refresh" (which is
> internally invoked from "status").
>
> If the feature still makes sense in the modern world is a
> different story, but I do find it useful.

I understand that it can be usefull, but I really don't like having it by default (is there a way to deactivate it BTW?):

I've hit this while working on a project, doing a lot of modifications through scripting (some regexp substitutions and such kinds of things). Then, git-diff shows me pages of "diff --git ...", and a few relevant entries in the middle of it. That's very bad from the usability point of view (I actually had some ~20 lines diff surrounded by 100+ irrelevant lines), and also kills performance: if a script touches a lot of files, I expect the next "diff" or "status" to be slow, but not the second next. Here, diff will be slow until I run git-status again.

And I find the "reminder" feature very fragile. That means git-status is no longer a read-only operation for the user. As a user, I expect to be able to run git-status without changing the behavior of subsequent git commands, which is not the case here. That means for example that someone used to running git-diff /before/ git-status will get the reminder, while someone used to running git-diff /after/ git-status (which I find sensible, get an overview before getting the details of what you did) won't get it. Note also that this makes a difference between git-status (which updates the stat in the index) and git-status -a (which doesn't). That's an implementation detail that shouldn't be exposed to the user.

Since I don't see any mention of this in the man pages for git-diff or git-status (I might have missed it), I wonder how many user actually ever used this as a feature.

I'd be in favor of disabling this by default, and providing a configuration option and/or a command line option to diff to enable it. I can try writting a patch for this if people agree on the specification.

-- 
Matthieu
Previous: Alexandre JulliardNext: Johannes Schindelin
Message 6 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.