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

Re: [FAQ?] Rationale for git's way to manage the index

From
Daniel Barkalow <barkalow@iabervon.org>
Date
May 9, 2007, 17:39 UTC
Message-ID
<Pine.LNX.4.64.0705091322180.18541@iabervon.org>
In-Reply-To
<alpine.LFD.0.98.0705090825090.4062@woody.linux-foundation.org>
On Wed, 9 May 2007, Linus Torvalds wrote:
Show 42 quoted lines
> Many people seem to enjoy per-hunk commits, but I seldom do that. Maybe 
> it's just because I'm *so* comfortable with diffs, that when I clean up an 
> ugly sequence of commits, what I do is literally:
> 
>  - I make sure that my ugly sequence of commits is on some temporary 
>    branch, but that the _end_result_ is good and clean (ie I will have 
>    tested the end result fairly well, and made sure that there are no 
>    debug statements etc crud left).
> 
>    I would call this branch something like "target", because the end 
>    result of that branch is what I'm looking for - even if the commits in 
>    the sequence that gets me there are individually ugly!
> 
>  - I just switch back to my starting point (and now I'm usually on 
>    "master"), and do
> 
> 	git diff -R target > diff
> 
>    to create a diff of my current tree (which is initially the starting 
>    point) to the good result.
> 
>  - I actually edit the "diff" file by hand, and edit it down to the part I 
>    actually want to commit as the first in the series. And then I just do 
>    a "git-apply diff" to actually apply that part to my working tree.
> 
>  - I then edit any missing parts in the actual working tree (for example, 
>    if there were mixed hunks that I want to get to in later commits, and I 
>    edited out above, or that I need to partially undo), to do any 
>    finishing touches.
> 
>  - I now have a tree I can compile and test, and has the "first part" of 
>    the journey towards the final "target" state. If compiling/testing 
>    shows that I missed something, I can still fix things, and/or go back 
>    to doing another "git diff -R target" to see if I missed something).
> 
>  - I commit that first case, and repeat the sequence from step 2 (and 
>    at every step, the "diff" file ends up shrinking and shrinking).
> 
> The above sounds like it's a complicated sequence, but it really isn't. 
> Partly because I just am very comfortable with diffs indeed (probably more 
> than most people), but partly because at all times "git diff" works fine 
> to see what I've done, and what the diff to "target" is.

It only sounds like a complicated sequence because you didn't write a script to do it...

$ git checkout -b clean origin
$ git-refine target
  (edit the patch in the editor that pops up)
$ git-refine
Test changes and commit
$ make test
...
$ git commit
  (write message)
$ git-refine
  (edit the patch, etc)
  ...
$ git commit
$ git-refine
All done.

I actually wrote it years ago, but I couldn't describe my workflow well enough, so I didn't submit it. If everybody seems to be doing the same thing, I can submit my script...

	-Daniel
*This .sig left intentionally blank*
Previous: J. Bruce FieldsNext: Linus Torvalds
Message 45 of 71 in “[FAQ?] Rationale for git's way to manage the index”
  1. Matthieu MoyMay 6, 2007
  2. Johannes SchindelinMay 6, 2007
  3. Matthieu MoyMay 6, 2007
  4. Junio C HamanoMay 6, 2007
  5. Petr BaudisMay 9, 2007
  6. Johannes SchindelinMay 9, 2007
  7. git-commit: Reformat log messages provided on commandlinePetr Baudis, May 9, 2007
  8. Matthieu MoyMay 9, 2007
  9. Petr BaudisMay 9, 2007
  10. Matthieu MoyMay 9, 2007
  11. Johannes SchindelinMay 9, 2007
  12. Junio C HamanoMay 10, 2007
  13. Jakub NarebskiMay 12, 2007
  14. Dana HowMay 6, 2007
  15. Johannes SchindelinMay 6, 2007
  16. Linus TorvaldsMay 6, 2007
  17. Matthieu MoyMay 6, 2007
  18. Linus TorvaldsMay 6, 2007
  19. Julian PhillipsMay 6, 2007
  20. Karl HasselströmMay 7, 2007
  21. Shawn O. PearceMay 8, 2007
  22. Johannes SixtMay 8, 2007
  23. Karl HasselströmMay 8, 2007
  24. J. Bruce FieldsMay 8, 2007
  25. Karl HasselströmMay 8, 2007
  26. J. Bruce FieldsMay 9, 2007
  27. Johannes SchindelinMay 9, 2007
  28. Karl HasselströmMay 8, 2007
  29. Shawn O. PearceMay 8, 2007
  30. Johannes SchindelinMay 6, 2007
  31. Matthieu MoyMay 7, 2007
  32. Johannes SchindelinMay 7, 2007
  33. Petr BaudisMay 9, 2007
  34. Martin LanghoffMay 8, 2007
  35. Linus TorvaldsMay 8, 2007
  36. Martin LanghoffMay 8, 2007
  37. Petr BaudisMay 9, 2007
  38. Linus TorvaldsMay 9, 2007
  39. Carl WorthMay 9, 2007
  40. Jakub NarebskiMay 11, 2007
  41. Dana HowMay 9, 2007
  42. J. Bruce FieldsMay 9, 2007
  43. Petr BaudisMay 9, 2007
  44. J. Bruce FieldsMay 9, 2007
  45. Daniel BarkalowMay 9, 2007
  46. Linus TorvaldsMay 9, 2007
  47. Junio C HamanoMay 10, 2007
  48. Steven GrimmMay 10, 2007
  49. Linus TorvaldsMay 10, 2007
  50. Matthieu MoyMay 10, 2007
  51. Shawn O. PearceMay 10, 2007
  52. Petr BaudisMay 10, 2007
  53. Johannes SchindelinMay 8, 2007
  54. David KågedalMay 15, 2007
  55. Johannes SchindelinMay 15, 2007
  56. Matthieu MoyMay 9, 2007
  57. Guilhem BonnefilleMay 7, 2007
  58. Karl HasselströmMay 7, 2007
  59. David KastrupMay 7, 2007
  60. Johannes SchindelinMay 7, 2007
  61. Junio C HamanoMay 7, 2007
  62. Petr BaudisMay 9, 2007
  63. Daniel BarkalowMay 7, 2007
  64. David KågedalMay 15, 2007
  65. Karl HasselströmMay 15, 2007
  66. Jakub NarebskiMay 11, 2007
  67. Junio C HamanoMay 11, 2007
  68. Jakub NarebskiMay 11, 2007
  69. Junio C HamanoMay 12, 2007
  70. Jakub NarebskiMay 12, 2007
  71. Jakub NarebskiMay 12, 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.