Duy Nguyen <pclouds@xxxxxxxxx> writes: > On Mon, Sep 17, 2018 at 7:09 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: >> ... >> On the other hand, if I am keeping some change that should never be >> in a commit in the working tree file, and building the contents in >> the index using "add -p" to incrementally, it would be the same >> disaster as you are trying to prevent if I by mistake did a whole >> path 'add', even if I catch myself doing so before running 'commit' >> i.e. >> >> edit X >> git add -p X >> git diff --cached X >> git diff X >> ... repeat the above number of times ... >> git add X ;# OOPS! >> git add . ;# OOPS! even worse! >> >> Even though this does not involve "git commit -a" or "git commit X", >> an unrecoverable damage that requires redoing the manual work is >> already done. > > I don't see a good way to get to recover this situation. I could go > back to the "index log" idea,... FWIW, I didn't mean to say that we should give users a way to recover. Your "commit -a" or "commit $path" protection just prevents the situation from happening, and I think it is sufficient. The sole point I wanted to raise by bringing up the above was that we should have the same degree of protection against "add $path" or "add -u". Of course, "index log" is interesting and it may even turn out to be useful (I was skeptical about "reference log" the same way, but it turned out to be useful without burdening the system too heavily), and it may even remove the need for the "do not accidentally lose information by adding more to the index" protection. But until that happens, if we are to have such a protection, we would wnat to give the same degree of protection to "commit" and "add".