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

Re: Two ideas for improving git's user interface

From
Junio C Hamano <junkio@cox.net>
Date
Feb 2, 2006, 02:25 UTC
Message-ID
<7vek2mzec5.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<87irrya7bx.wl%cworth@cworth.org>
Carl Worth <cworth@cworth.org> writes:
> If not, we should be able to simplify things since a lot of the
> UI complexity being discussed (-a vs. no -a, path names vs. no path
> names), hinges on the handling of skewed files.

I am in agreement with you that "skewed files" might lead to confusion, but I do not see how that relates to "-a vs no -a" nor "path names vs no path names" issues.

Let's say we try to detect and forbid committing skewed files. How would we do that? For the sake of clarity, let's say we fixed the commit command the way I said in the message you are responding.

Now:
1. "git commit" is the traditional one; it commits the current index.
   We enumerate paths that 'git-diff-index --cached --name-only HEAD'
   tells are different (they are the paths to be committed -- what
   about merges?  Maybe take union from all parents?).  Then we see if
   the paths from "git-diff-files --name-only" (locally modified
   files) overlap with them.  Overlapping ones will be skewed if we
   make a commit.
2. "git commit --also fileA..." updates fileA... on top of the current
   index and commits that.  After doing "git update-index fileA...",
   the story is the same as the previous case.
3. "git commit fileA..." initializes a temporary index from the
   current HEAD, updates fileA... and commits that.  We would need a
   check to make sure index matches HEAD at specified paths, but after
   that check passes, there is no skewed files being committed and
   there is nothing more to check.
4. "git commit -a" by definition would not have skewed files and there
   is nothing to check.

So what you say sounds doable. But I wonder if that really helps much.

Let's say we want to give an interface to a class of users who do _not_ want to worry about the presense of the index file. That means they will _never_ run "git update-index" themselves, although "git commit", "git add", and "git merge" may run update-index for them internally. Essentially, you tell them to always use "git commit -a" or "git commit fileA...", and do not teach them "git commit", "git commit --also fileA...". IOW they will be doing only 3 or 4. In this case, we do not need any of the "skewed files" check.

The extra checks in 1 and 2 would prevent index-unaware users from making obvious mistakes, but if they do not understand index then they would still be surprised anyway. For example, "git commit" commits the files they previously run "git add" on, but leaves other modified files in the working tree uncommitted. This is different from either 3 or 4 that they have learned so far. If they did "git commit fileA", the file earlier they run "git add" is not committed. If they did "git commit -a", files other than the added files are also committed. So in that sense the above checks are doable but I do not think it helps that much to alleviate the confusion.

These extra checks in 1 and 2 may protect index-aware users from making mistakes, to a certain degree. I am not convinced enough myself to pay the cost of extra checks, though, because my workflow is to do the final review exactly like what you said below.

> My workflow has been to always perform a final review of such a diff
> while composing the commit message. I'd like to be able to do that
> with git.

That matches my workflow. I do either one of these (I never use "git commit paths..."):

	$ work work work
        $ I may do update-index [--add|--remove] here
        $ git diff --cached
        $ git commit
	$ work work work
        $ I may do update-index [--add|--remove] here
        $ git diff HEAD
        $ git commit -a

In either cases "skewed files" do not matter. This can be summarized in a short paragraph:

	If you are going to commit with "git commit" (no parameters),
	check the final result with "git diff --cached".  If you are
	going to commit with "git commit -a", check with "git diff
	HEAD".

I said why I do not do "git commit paths..." myself, but I think this "skewed files" discussion adds another thing to be careful about if you use it. If you do this (with the current tool, you drop --also):

	$ work on file A
        $ git diff A
        ... that looks fine so far ...
        $ git update-index A
        $ work more on file A
        $ git diff A
        ... incrementally that looks fine ...
        $ git commit --also A

you would end up commiting something you have not done the "final review". You need to have the final check before such a commit:

	$ work on file A
        $ git diff A
        ... that looks fine so far ...
        $ git update-index A
        $ work more on file A
        $ git diff A
        ... incrementally that looks fine ...
 +++++  $ git diff HEAD
        $ git commit --also A

This includes all changes that are not in the index and are not going to be included in the commit (i.e. changes to files other than A). For that you may need to do something like:

	git-diff-index --cached HEAD ;# already in index but do not look at A
        git-diff-index HEAD -- A ;# and path A is taken from working tree
which is a bit cumbersome.

Without --also (the new semantics), the check would be straightforward:

	$ work on file A
        $ git diff A
        ... that looks fine so far ...
        $ git update-index A
        $ work more on file A
        $ git diff A
        ... incrementally that looks fine ...
 +++++  $ git diff HEAD -- A
	$ git commit A
Previous: Carl WorthNext: Carl Worth
Message 70 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.