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

Re: Two ideas for improving git's user interface

From
Alan Chandler <alan@chandlerfamily.org.uk>
Date
Feb 4, 2006, 08:03 UTC
Message-ID
<200602040803.45617.alan@chandlerfamily.org.uk>
In-Reply-To
<Pine.LNX.4.64.0602011732560.21884@g5.osdl.org>
On Thursday 02 February 2006 01:44, Linus Torvalds wrote:
Show 28 quoted lines
> On Wed, 1 Feb 2006, Linus Torvalds wrote:
> > And notice how I commit the _merge_ without actually committing my dirty
> > state in the tree - and whether the files involved in my standard dirty
> > changes ("Makefile") are part of the state that the merge changed or not
> > is _totally_ irrelevant.
>
> If you get the feeling that merging is special, then to some degree, yes,
> you'd be right.
>
> Merging (especially with conflicts) is the _one_ operation where you
> absolutely have to know about the index. If you don't know about how the
> index works, you can get the conflict resolution right kind of by
> accident, simply because the default workflow of
>
> 	.. edit conflict to look ok ..
> 	git commit file/with/conflict
>
> actually happens to do exactly the right thing (very much on purpose,
> btw), but the fact is, to actually figure out more complicated conflicts
> and to _understand_ what happens, you absolutely need to be aware of the
> index. Not being aware of it just isn't an option for any serious git
> user.
>
> (Btw, I think this is where cogito falls down. Cogito tries to hide the
> index file, but I don't think you really _can_ hide the index file and
> also do merges well at the same time. Anybody who has non-trivial merges
> should use raw git - not just because the "recursive" strategy just works
> better, but exactly because of the index file issue).
Wow - light comes on.

I have been using git (or rather to be exact git with cg-add, cg-rm and cg-commit) for about 6 months (bearing in mind I am only a part time programmer in the evenings for fun - even though I work in the computer industry the last time I was paid to write code was in 1979 - so I don't really need to be a power user). Although I knew about the index file since the beginning I never really groked what it was about before.

Of course I knew of its existance, and I even knew that it could be used as a staging area, but up to now I had always thought of it as a necessary inconvenience to enable git to run as blazingly fast as it does - not as an essential part of work flow it complex situations

I think the problem is with three crucial bits of documentation. Firstly, the document is full of the git doesn't do prorcelain statements - pushing towards cogito which then hides the existance of the index file. Git not doing porcelain was true at the very beginning, but I don't think that it is true any longer.

Secondly the tutorial. The examples given start by using commands to explicitly update the index and them they move on to show how you don't need to do that by using the more advanced commands of git-add and git-commit. So as I was trying to learn how to use git, I followed through this and thought that you just try an avoid using it directly. Whats more, viewed in this light git-commit seemed to be a rather poor implementation of cogito's superior cg-commit command

[Incidentally there is a use case that doesn't seem to have been discussed in this thread which I use cg-commit all the time for and will now have to see if there is a use index file equivalence for. That is, I am developing a web application and in the running version the database framework (iBatis) is using Tomcats connection pooling. In order to run my JUnit test harness, I don't have tomcat, so I need to define a different version of iBatis configuration file to used its own database connection. So I have created a test branch and edited the configuration file in that branch, and I update both code and tests in a edit/compile/fix and text loop until I have written or changed both code and tests. I then do a cg-commit which lists the files I have changed. I ONLY commit those in the test harness - by deleting the others from cogito's list of files to commit - and then repeat the commit commiting the rest]. I then switch back to my master branch and cherry pick commit that is the code changes - not the text harness]

Thirdly, "discussion" of the index file at the bottom end of the git man page (The "index" aka "Current Directory Cache") really concentrates on what it is and what operations you can perform with it in the normal situation.

I tried looking at the core tutorial looking at what I might be a way of bring this to the attention of the new learner into git and produced the following (partial) patch to the core-tutorial (It needs a whole set of examples on resolving merge problems which I have no idea at the moment how to do - this has been the real area which never understood - basically because the tutorial itself says skip that part).

--- a/Documentation/core-tutorial.txt
+++ b/Documentation/core-tutorial.txt
@@ -212,15 +212,22 @@ was just to show that `git-update-index`
 actually saved away the contents of your files into the git object
 database.

+The Index File
+--------------
+
 Updating the index did something else too: it created a `.git/index`
 file. This is the index that describes your current working tree, and
-something you should be very aware of. Again, you normally never worry
-about the index file itself, but you should be aware of the fact that
-you have not actually really "checked in" your files into git so far,
-you've only *told* git about them.
+something you should be very aware of.  It is a staging area between your
+working tree and the object store described above.
+
+In normal circumstances you do not worry about the index file itself, but you
+should be aware of the fact that you have not actually really "checked in"
+your files into git so far, you've only *told* git about them.  Later you
+will see how you can exploit the fact that there is this separate index
+file to undertake more complex operations.

-However, since git knows about them, you can now start using some of the
-most basic git commands to manipulate the files or look at their status.
+However, since git knows about these files, you can now start using some of
+the most basic git commands to manipulate them or look at their status.

 In particular, let's not even check in the two files into git yet, we'll
 start off by adding another line to `hello` first:
@@ -1188,8 +1195,8 @@ How does the merge work?
 We said this tutorial shows what plumbing does to help you cope
 with the porcelain that isn't flushing, but we so far did not
 talk about how the merge really works.  If you are following
-this tutorial the first time, I'd suggest to skip to "Publishing
-your work" section and come back here later.
+this tutorial the first time, I'd suggest to skip to "Resolving Merge
+Problems" section and come back here later.

 OK, still with me?  To give us an example to look at, let's go
 back to the earlier repository with "hello" and "example" file,
@@ -1332,6 +1339,10 @@ merge for you to resolve.  Notice that t
 unmerged, and what you see with `git diff` at this point is
 differences since stage 2 (i.e. your version).

+Resolving Merge Problems
+------------------------
+
+NOT SURE WHAT GOES HERE

 Publishing your work
 --------------------
-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
Previous: Linus TorvaldsNext: Junio C Hamano
Message 74 of 105 in “LCA06 Cogito/GIT workshop - (Re: git-whatchanged: exit out early on errors)”
  1. Martin LanghoffJan 26, 2006
  2. Linus TorvaldsJan 28, 2006
  3. Martin LanghoffJan 28, 2006
  4. Linus TorvaldsJan 28, 2006
  5. Junio C HamanoJan 28, 2006
  6. Fredrik KuivinenJan 29, 2006
  7. Junio C HamanoJan 29, 2006
  8. Keith PackardJan 28, 2006
  9. [Census] So who uses git?Junio C Hamano, Jan 28, 2006
  10. Morten WelinderJan 29, 2006
  11. Junio C HamanoJan 29, 2006
  12. Morten WelinderJan 29, 2006
  13. Junio C HamanoJan 29, 2006
  14. Keith PackardJan 29, 2006
  15. Radoslaw SzkodzinskiJan 29, 2006
  16. Greg KHJan 29, 2006
  17. Radoslaw SzkodzinskiJan 31, 2006
  18. Radoslaw SzkodzinskiJan 31, 2006
  19. Junio C HamanoJan 31, 2006
  20. Radoslaw SzkodzinskiJan 31, 2006
  21. Alex RiesenJan 30, 2006
  22. Linus TorvaldsJan 31, 2006
  23. J. Bruce FieldsJan 31, 2006
  24. Alex RiesenJan 31, 2006
  25. Dave JonesJan 29, 2006
  26. Daniel BarkalowJan 29, 2006
  27. Martin LanghoffJan 29, 2006
  28. Mike McCormackJan 30, 2006
  29. Carl BaldwinJan 30, 2006
  30. Johannes SchindelinJan 31, 2006
  31. Carl BaldwinJan 31, 2006
  32. Johannes SchindelinJan 31, 2006
  33. Linus TorvaldsJan 31, 2006
  34. J. Bruce FieldsJan 31, 2006
  35. Junio C HamanoJan 31, 2006
  36. Jon LoeligerJan 31, 2006
  37. Junio C HamanoJan 31, 2006
  38. J. Bruce FieldsJan 31, 2006
  39. Keith PackardJan 31, 2006
  40. Linus TorvaldsJan 31, 2006
  41. Joel BeckerJan 31, 2006
  42. Johannes SchindelinFeb 1, 2006
  43. Sam RavnborgJan 31, 2006
  44. Junio C HamanoJan 31, 2006
  45. H. Peter AnvinFeb 1, 2006
  46. Daniel BarkalowJan 31, 2006
  47. Petr BaudisJan 31, 2006
  48. Junio C HamanoJan 31, 2006
  49. Linus TorvaldsFeb 1, 2006
  50. Junio C HamanoFeb 1, 2006
  51. Daniel BarkalowFeb 1, 2006
  52. Junio C HamanoFeb 1, 2006
  53. Carl WorthFeb 1, 2006
  54. Junio C HamanoFeb 1, 2006
  55. Randal L. SchwartzFeb 1, 2006
  56. Junio C HamanoFeb 1, 2006
  57. Linus TorvaldsFeb 1, 2006
  58. Nicolas PitreFeb 1, 2006
  59. Junio C HamanoFeb 1, 2006
  60. Linus TorvaldsFeb 1, 2006
  61. Nicolas PitreFeb 1, 2006
  62. Junio C HamanoFeb 1, 2006
  63. Nicolas PitreFeb 1, 2006
  64. Junio C HamanoFeb 1, 2006
  65. Andreas EricssonFeb 2, 2006
  66. Linus TorvaldsFeb 1, 2006
  67. Two ideas for improving git's user interfaceCarl Worth, Feb 1, 2006
  68. Junio C HamanoFeb 2, 2006
  69. Carl WorthFeb 2, 2006
  70. Junio C HamanoFeb 2, 2006
  71. Carl WorthFeb 3, 2006
  72. Linus TorvaldsFeb 2, 2006
  73. Linus TorvaldsFeb 2, 2006
  74. Alan ChandlerFeb 4, 2006
  75. Junio C HamanoFeb 4, 2006
  76. Alan ChandlerFeb 4, 2006
  77. Carl WorthFeb 4, 2006
  78. Linus TorvaldsFeb 4, 2006
  79. Carl WorthFeb 6, 2006
  80. Florian WeimerFeb 2, 2006
  81. Carl BaldwinFeb 2, 2006
  82. Daniel BarkalowFeb 1, 2006
  83. Joel BeckerFeb 1, 2006
  84. H. Peter AnvinFeb 1, 2006
  85. J. Bruce FieldsJan 31, 2006
  86. Linus TorvaldsFeb 1, 2006
  87. Linus TorvaldsFeb 1, 2006
  88. "Assume unchanged" gitJunio C Hamano, Feb 9, 2006
  89. "Assume unchanged" git: do not set CE_VALID with --refreshJunio C Hamano, Feb 9, 2006
  90. ls-files: debugging aid for CE_VALID changes.Junio C Hamano, Feb 9, 2006
  91. Junio C HamanoFeb 1, 2006
  92. Linus TorvaldsFeb 1, 2006
  93. Junio C HamanoFeb 1, 2006
  94. Jason RiedyFeb 1, 2006
  95. Julian PhillipsFeb 1, 2006
  96. Linus TorvaldsFeb 1, 2006
  97. Chuck LeverFeb 6, 2006
  98. Martin LanghoffFeb 1, 2006
  99. Linus TorvaldsFeb 1, 2006
  100. H. Peter AnvinFeb 1, 2006
  101. Alex RiesenFeb 1, 2006
  102. Linus TorvaldsFeb 1, 2006
  103. Alex RiesenFeb 2, 2006
  104. Linus TorvaldsFeb 1, 2006
  105. Junio C HamanoFeb 1, 2006

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.