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
Karl Hasselström <kha@treskal.com>
Date
May 8, 2007, 07:37 UTC
Message-ID
<20070508073739.GA24409@diana.vm.bytemark.co.uk>
In-Reply-To
<20070508014114.GC11311@spearce.org>
On 2007-05-07 21:41:14 -0400, Shawn O. Pearce wrote:
Show 10 quoted lines
> Karl Hasselström <kha@treskal.com> wrote:
>
> > I thought "git add -i" was the best thing since sliced bread --
> > until I found the same feature in git-gui, but with a _much_
> > better interface. Just right-click on a hunk in a diff, and you
> > have the option of staging/unstaging that hunk. Pure magic.
>
> "git add -i" has a hunk splitting feature that git-gui lacks. I'm
> thinking of adding features to git-gui to let you select a region of
> a hunk using the text selection, and then stage only that selection.

That would be useful. It's currently possible to split some hunks by reducing the number of content lines, but if the changes aren't separated by any unchanged lines at all, that doesn't work.

> I also want to let you revert hunks from the working directory copy.

That would be handy. But unlike stage/unstage, this can lose information, so there'd need to be some kind of "are you _really_ sure? [Yes] [No]" safety hatch, which would make it less convenient.

Show 5 quoted lines
> But after reading Junio's comments about "git add -i" being a
> possibly bad idea and instead letting you park everything into a
> shelf, reset --hard your working directory to HEAD and then pull
> things back off the shelf to be staged, I might want to do that
> differently in git-gui... like use a shelf. ;-)

A shelf could be handy. Actually, it could be handy to have more than one. Then one could go through the mess in one's working directory and toss changes into one bin for each commit one plans to create -- including one "trash" bin for hunks one would like to revert.

I assume that shelves would be implemented as branches that are precisely one commit on top of HEAD? If so, I'd just like to point out that they're exactly like unapplied patches in StGIT.

Hmm. I find it inconsistent to force or strongly encourage the user to commit precisely the working directory changes and not a subset thereof, which the shelf idea seems to encourage, while at the same time not committing straight from the working directory but from a specific staging area (the index).

> But I'm glad someone else finds the hunk feature useful in git-gui.
> I use it far too often myself.

I don't think it's a bad thing. If I've made several unrelated changes and want to commit them separately for the sake of readable history, how exactly is that a bad thing when compared to committing it all at once? If I care about clean history in the first place, then presumably I'll test the commits in isolation if I deem it necessary -- and if I don't, then I probably won't test anyway even if the tool makes it easy.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Previous: Johannes SchindelinNext: Shawn O. Pearce
Message 28 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.