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, 20:01 UTC
Message-ID
<7vippxgm6y.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1313158058-7684-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> What I want is a quick way to modify index content without changing
> worktree, then I can continue adding more hunks to the index.
Why would you even want to do that?

Suppose you want to update hello.c in the index but not in the working tree for whatever reason I do not understand. Presumably you would with this patch do this:

	edit hello.c
        git update-index --swap hello.c

assuming that the state of hello.c _before_ the edit was pristine. But then after that what would you do? Probably you would commit that untested change, and rebase-i to clean them up later, which is fine.

BUT

After swapping, the file in the working tree lacks the change you made to the index, so if you keep working on it after the above "swap" in your editor, the next "git add" will revert whatever you did with the first "edit".

I think that makes it too error prone and difficult to understand for both new and experienced people.

Whatever the expected use case is, it needs to be explained a lot better.
Previous: Nguyen Thai Ngoc DuyNext: Jeff King
Message 4 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.