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

Re: seperate commits for objects already updated in index?

From
Andreas Ericsson <ae@op5.se>
Date
Mar 15, 2006, 14:00 UTC
Message-ID
<44181DFE.7080204@op5.se>
In-Reply-To
<7vy7zcie5c.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 41 quoted lines
> The background behind this is around beginning of February 2006,
> the thread "Two ideas" by Carl Worth.  And the current behaviour
> is defined by this commit.  I'll talk about a possible
> improvement but first, here is what it does:
> 
> commit 130fcca63fe8e7e087e7419907e018cbbaf434a3
> Author: Junio C Hamano <junkio@cox.net>
> Date:   Sun Feb 5 00:07:44 2006 -0800
> 
>     
>        2. refuses to run if named paths... are different in HEAD and
>           the index (ditto about reminding).  Added paths are OK.
>     
> 
> The check that prevents you from doing
> 
> 	$ edit A B
> 	$ git update-index A B
>         $ git commit -o B
> 
> is the rule #2, which I think could use further improvement.  It
> is to address the "committing skewed files" issue Carl brought
> up in that thread.
> 
> It might be better to further check if the working tree file is
> the same as the index, and to allow a commit in such a case.
> 
> The intent of rule #2 is to prevent this from happening:
> 
> 	$ edit A B
>         $ git update-index A B
>         $ edit B again
>         $ git commit -o B
> 
> When this happens, the real index will have _old_ contents of B
> that never was committed, and does not match what is in the
> index.  But after the commit, we will match the real index to
> what was committed, so we will _lose_ the index entry for B
> before the second edit you explicitly told git to remember by
> saying 'update-index'.
> 

Can't this be done by updating .git/index first and then use the temporary index to commit? Then .git/index would match the current tree and everybody would be happy with very little tweaking. Doing the temporary index commit first could cause data-loss as described above if the updating of .git/index somehow fails and the user is unaware of it (or what to do to fix it).

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Paul JakmaNext: Junio C Hamano
Message 9 of 11 in “seperate commits for objects already updated in index?”
  1. Paul JakmaMar 14, 2006
  2. Linus TorvaldsMar 14, 2006
  3. Paul JakmaMar 14, 2006
  4. Linus TorvaldsMar 14, 2006
  5. Paul JakmaMar 14, 2006
  6. Junio C HamanoMar 14, 2006
  7. Junio C HamanoMar 15, 2006
  8. Paul JakmaMar 15, 2006
  9. Andreas EricssonMar 15, 2006
  10. Junio C HamanoMar 15, 2006
  11. Andreas EricssonMar 15, 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.