Subject: [PATCH v4 0/5] Re: {checkout,reset,stash} --patch

From: Nicolas Sebrecht <[email-masked]>
Date: Sun, 9 Aug 2009 23:28:31 +0200

The 09/08/09, Thomas Rast wrote:
> Nicolas Sebrecht wrote:
> > 
> > Also, I'd expect to have 'git reset --hard -p' discarding hunks from
> > both the index and the WT (which is not possible for now unless I missed
> > something).
> 
> Well, the unfortunate overlap between 'git reset --hard' and 'git
> checkout HEAD -- .' strikes again :-)
> 
> Since you can't say 'git reset --hard -- file', you have to do 'git
> checkout HEAD -- file' to achieve this effect.  So this usage is
> covered by 'git checkout -p HEAD'.

Not exactly:

  Current branch: my_branch (clean)
  nicolas@vidovic git % echo 'hi' > file
  Current branch: my_branch (dirty: untracked:1)
  nicolas@vidovic git % git add file
  Current branch: my_branch (dirty: index)
  nicolas@vidovic git % git checkout -p
  No changes.

Same example with an already tracked file:

  Current branch: my_branch (clean)
  nicolas@vidovic git % echo 'hi Thomas' >> Documentation/SubmittingPatches
  Current branch: my_branch (dirty: working_tree)
  nicolas@vidovic git % git add Documentation/SubmittingPatches
  Current branch: my_branch (dirty: index)
  nicolas@vidovic git % git checkout -p
  No changes.

So, we can discard a hunk from the index with 'git reset -p' without
touching the WT. And we can discard a hunk from the WT with 'git
checkout -p' without touching the index. But we can't discard a hunk
from both the index and the WT.

IOW, we have (from the user POV):

  .git --- (reset -p) ---> index
                           index --- (checkout -p) ---> WT

What's missing:

  .git ------------------ ( ??? ) --------------------> WT

-- 
Nicolas Sebrecht