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

Re: [PATCH] update-index: add --swap to swap index and worktree content

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 16, 2011, 21:56 UTC
Message-ID
<7vbovpggva.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110816210108.GA13710@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
>   # add some content with an error
>   echo 'printf("hello word!\n")' >hello.c
>   git add hello.c
>
>   # work on it more, realizing the error
>   echo 'printf("goodbye world!\n") >hello.c
>
>   # now what? you want to stage the s/word/world/ fixup,
>   # but you want to keep the hello/goodbye thing as a separate change.
>   # Using anything line-based is going to conflate the two.
>   # The change is simple, though, so you can just as easily edit the
>   # index file, if only you could get to it. So you do:
>   git update-index --swap hello.c
>   sed -i s/word/world/ hello.c
>   git update-index --swap hello.c
>
> So the swap really functions as a toggle of "I would like to work on
> the index version for a minute", and then you toggle back when you're
> done.

And you have to redo what you did to the index version in the working tree after the second "swap", no?

Previous: Jeff KingNext: Jeff King
Message 6 of 16 in “update-index: add --swap to swap index and worktree content”
  1. update-index: add --swap to swap index and worktree contentNguyễn Thái Ngọc Duy, Aug 12, 2011
  2. Michael J GruberAug 16, 2011
  3. Nguyen Thai Ngoc DuyAug 16, 2011
  4. Junio C HamanoAug 16, 2011
  5. Jeff KingAug 16, 2011
  6. Junio C HamanoAug 16, 2011
  7. Jeff KingAug 16, 2011
  8. Junio C HamanoAug 16, 2011
  9. Jeff KingAug 16, 2011
  10. Nguyen Thai Ngoc DuyAug 17, 2011
  11. Jeff KingAug 17, 2011
  12. Martin von ZweigbergkAug 17, 2011
  13. Nguyen Thai Ngoc DuyAug 17, 2011
  14. Junio C HamanoAug 17, 2011
  15. Jeff KingAug 17, 2011
  16. Martin von ZweigbergkAug 18, 2011

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.