Re: [PATCH] update-index: add --swap to swap index and worktree content
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:49
Nguyễn Thái Ngọc Duy [off-list ref] 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.