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

[PATCH v2 try2 00/14] Officially start moving to the term 'staging area'

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 25, 2014, 18:12 UTC
Message-ID
<1398449567-16314-1-git-send-email-felipe.contreras@gmail.com>

tl;dr: everyone except Junio C Hamano and Drew Northup agrees; we should move away from the name "the index".

It has been discussed many times in the past that 'index' is not an appropriate description for what the high-level user does with it, and it has been agreed that 'staging area' is the best term.

The term 'staging area' is more intuitive for newcomers which are more familiar with English than with Git, and it seems to be a straightforward mental notion for people with different mother tongues.

In fact it is so intuitive that it's used already in a lot online documentation, and the people that do teach Git professionally use this term, because it's easier for many kinds of audiences to grasp.

The meaning of the words 'cache' and 'index' doesn't represent correctly the mental model of the high-level user:

cache: a 'cache' is a place for easier access; a squirrel caches nuts so it doesn't have to go looking for them in the future when it might be much more difficult. Git porcelain is not using the staging area for easier future access; it's not a cache.

index: an 'index' is a guide of pointers to something else; a book index has a list of entries so the reader can locate information easily without having to go through the whole book. Git porcelain is not using the staging area to find out entries quicker; it's not an index.

stage: a 'stage' is a special area designated for convenience in order for some activity to take place; an orator would prepare a stage in order for her speak to be successful, otherwise many people might not be able to hear, or see her. Git porcelain is using the staging area precisely as a special area to be separated from the working directory for convenience.

The term 'stage' is a good noun itself, but also 'staging area', it has a good verb; 'to stage', and a nice past-participle; 'staged'.

The first step in moving Git towards this term, is first to add --stage options for every command that uses --index or --cache. However, there's a problem with the 'git apply' command, because it treats --index and --cache differently. Different solutions were proposed, including a special --stage-only option, however, I think the best solution is a --[no-]work option to specify if the working directory should be touched or not, so --index becomes --staged, and --cached becomes --staged --no-work.

In addition, the 'git stage' command can be extended so the staging area can be brought closer to the user, like other important Git concepts, like 'git branch, 'git tag', and 'git remote'. For example, the command 'git stage edit' (which allows the user to edit directly the diff from HEAD to the staging area) can have a home, where previously there was no place. It would become natural then to do 'git stage diff', and then 'git stage edit' (to edit the previous diff).

After adding the new --stage options and making sure no functionality is lost, they can become the recommended ones in the documentation, eventually, the old ones get deprecated, and eventually obsoleted.

Also, the documentation would need to be updated to replace many instances of 'the index', with 'the staging area' in porcelain commands.

Moreover, the --stage and --work options also make sense for 'git reset', and after these options are added, the complicated table to explain the different behaviors between --soft, --mixed, and --hard becomes so simple it's not needed any more:

      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       A       B     C    D     --no-stage  A       B     D
				--stage     A       D     D
				--work      D       D     D
      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       A       B     C    C     --no-stage  A       B     C
				--stage     A       C     C
				--work      C       C     C
      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       B       B     C    D     --no-stage  B       B     D
				--stage     B       D     D
				--work      D       D     D
      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       B       B     C    C     --no-stage  B       B     C
				--stage     B       C     C
				--work      C       C     C
      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       B       C     C    D     --no-stage  B       C     D
				--stage     B       D     D
				--work      D       D     D
      working stage HEAD target             working stage HEAD
      ----------------------------------------------------
       B       C     C    C     --no-stage  B       C     C
				--stage     B       C     C
				--work      C       C     C

It might be possible to do 'git reset --no-stage --work', to reset the working directory, but leave the staging area alone.

For more reference about the previous discussions:

http://thread.gmane.org/gmane.comp.version-control.git/197111 http://thread.gmane.org/gmane.comp.version-control.git/166675 http://thread.gmane.org/gmane.comp.version-control.git/115666 http://thread.gmane.org/gmane.comp.version-control.git/233295

I made a summary of all the positions shared towards moving away from the name "index".

http://article.gmane.org/gmane.comp.version-control.git/233469
Felipe Contreras (14):
  Add proper 'stage' command
  stage: add edit command
  diff: document --staged
  grep: add --staged option
  rm: add --staged option
  stash: add --stage option to save
  stash: add --stage to pop and apply
  submodule: add --staged options
  apply: add --stage option
  apply: add --work, --no-work options
  completion: update --staged options
  reset: add --stage and --work options
  reset: allow --keep with --stage
  completion: update 'git reset' new stage options
 Documentation/git-apply.txt            |  11 ++-
 Documentation/git-diff.txt             |   4 +-
 Documentation/git-grep.txt             |   5 +-
 Documentation/git-reset.txt            |   8 +++
 Documentation/git-rm.txt               |   5 +-
 Documentation/git-stage.txt            |  51 +++++++++++--
 Documentation/git-stash.txt            |  14 ++--
 Documentation/git-submodule.txt        |   8 ++-
 Makefile                               |   2 +-
 builtin.h                              |   1 +
 builtin/apply.c                        |   7 ++
 builtin/grep.c                         |   2 +
 builtin/reset.c                        |  27 +++++++
 builtin/rm.c                           |   1 +
 builtin/stage.c                        | 127 +++++++++++++++++++++++++++++++++
 contrib/completion/git-completion.bash |  39 ++++++++--
 git-stash.sh                           |  12 +++-
 git-submodule.sh                       |  10 +--
 git.c                                  |   2 +-
 19 files changed, 299 insertions(+), 37 deletions(-)
 create mode 100644 builtin/stage.c
-- 
1.9.2+fc1.2.gfbaae8c
Next: Felipe Contreras
Message 1 of 16 in “Officially start moving to the term 'staging area'”
  1. 00/14 Officially start moving to the term 'staging area'Felipe Contreras, Apr 25, 2014
  2. 01/14 Add proper 'stage' commandFelipe Contreras, Apr 25, 2014
  3. 02/14 stage: add edit commandFelipe Contreras, Apr 25, 2014
  4. 03/14 diff: document --stagedFelipe Contreras, Apr 25, 2014
  5. 04/14 grep: add --staged optionFelipe Contreras, Apr 25, 2014
  6. 05/14 rm: add --staged optionFelipe Contreras, Apr 25, 2014
  7. 06/14 stash: add --stage option to saveFelipe Contreras, Apr 25, 2014
  8. 07/14 stash: add --stage to pop and applyFelipe Contreras, Apr 25, 2014
  9. 08/14 submodule: add --staged optionsFelipe Contreras, Apr 25, 2014
  10. 09/14 apply: add --stage optionFelipe Contreras, Apr 25, 2014
  11. 10/14 apply: add --work, --no-work optionsFelipe Contreras, Apr 25, 2014
  12. 11/14 completion: update --staged optionsFelipe Contreras, Apr 25, 2014
  13. 12/14 reset: add --stage and --work optionsFelipe Contreras, Apr 25, 2014
  14. 13/14 reset: allow --keep with --stageFelipe Contreras, Apr 25, 2014
  15. 14/14 completion: update 'git reset' new stage optionsFelipe Contreras, Apr 25, 2014
  16. Hilco WijbengaApr 26, 2014

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.