On Fri, Aug 24, 2018 at 7:42 AM Duy Nguyen <pclouds@xxxxxxxxx> wrote: > > On Fri, Aug 24, 2018 at 5:02 AM Jacob Keller <jacob.keller@xxxxxxxxx> wrote: > > > > On Thu, Aug 23, 2018 at 9:28 AM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > > I think the above example forgets "-a" on the final "git commit" > > > step. With it added, I can understand the concern (and I am sure > > > you would, too). > > > > > > The user is trying to add everything done in the working tree, and > > > "commit -a" would catch all changes to paths that were already > > > tracked, but a separate "add" is necessary for newly created paths. > > > But adding a new path means the index no longer matches HEAD, and > > > the "commit -a" at the final step sweeps the changes to already > > > tracked paths---failing that because there "already is something > > > staged" will break the workflow. > > > > Right. I think this would need to be able to understand the case of > > "different only by new files". > > OK so the rules I'm going to try to implement is, if the version in > the index is not the same as one in HEAD or one in worktree, then "git > commit -a" fails. > > The unwritten line is, if the path in question does not exist in HEAD, > then the first condition "as one in HEAD" is dropped, naturally. This > addresses the "git add new-file" problem, but if you have made more > changes in new-file in worktree after "git add" and do "git commit -a" > then you still get rejected because it fails the second condition. > > File removal should be considered as well. But I don't foresee any > problem there. Resolving merges, replacing higher stage entries with > stage 0 will be accepted at "git commit -a" as usual. > > Let me know if we should tweak these rules (and how). > -- > Duy This seems reasonable to me. It might trigger a few issues with people doing "git add new_file ; $EDITOR new_file ; git commit -a" but... I know I've accidentally done "git commit -a" and had problems. What about "git commit <file>"? That's another case where I've accidentally lost some work for a similar reason. Thanks, Jake