Re: [PATCH v5 2/3] apply: make i-t-a entries never match worktree
- From
Raymond E. Pasco <ray@ameretat.dev>
- Date
- Aug 8, 2020, 14:07 UTC
- Message-ID
- <C4RO9JSUGPKG.2UQX61X628B6P@ziyou.local>
- In-Reply-To
- <db1c56f6-bcd2-bbd9-aa63-70d54215cd44@gmail.com>
On Sat Aug 8, 2020 at 9:46 AM EDT, Phillip Wood wrote:
Show 7 quoted lines
> > By definition, an intent-to-add index entry can never match the > > worktree, because worktrees have no concept of intent-to-add entries. > > Therefore, "apply --index" should always fail on intent-to-add paths. > > I'm not sure I understand the logic for this. If I run 'git add -N > <path>' and <path> does not exist in the worktree what's the reason to > stop a patch that creates <path> from applying?
"apply --index" requires the index and worktree to match, and applies the same path to both to get the same result in both. I brainstormed the logic a few emails upthread, and that's what's consistent with everything else.
Show 5 quoted lines
> I was relieved to see from the next patch that this does not affect > --cached even though the documentation says it implies --index. It might > be worth mentioning that in the commit message. Also it would be easier > to follow if the tests were in the same patch (this is what we usually > do).
--cached doesn't really imply --index - the docs are wrong and should be changed. If anything, --index is closer to implying --cached - but really, [no flags], --cached, and --index are three different modes with different behavior. (Just removing "this implies --index" would be sufficient to make the docs correct.)
> How this does it affect --check? `git add -p` uses --check to verify > that hunks that the user has edited still apply. It does not let the > user edit the hunk for a newly added file at the moment but that is > something I'm thinking of adding.
--check goes through all the same code, it just doesn't actually touch anything in the index or worktree. Splittable/editable new file patches are a logical related feature, IMO. (This is just to squash an error that shouldn't happen.)