"Dmitry V. Levin" <ldv@xxxxxxxxxxxx> wrote: > On Wed, Sep 05, 2007 at 10:25:39PM -0400, Shawn O. Pearce wrote: > > "Dmitry V. Levin" <ldv@xxxxxxxxxxxx> wrote: > > > Do not commit an unchanged tree in non-merge mode. > > > > NO. `git commit --amend` is *often* used for fixing the commit > > message. > > You see, my proposed change does not affect this usage case at all. OK, I was too rash on my original reply. I think the change you were going after was to try and prevent the user from ever keeping a commit that has the same tree as its parent and which is not a merge commit, as such commits are generally useless. That's actually what I expect git-commit to be doing today, and if it is not doing that then it really should be taught to be avoid it. I guess that's what your patch was about. So I take back my "NO". > > > + if test "$tree" = "$current_tree" > > > + then > > > + echo >&2 "nothing to commit${amend:+ (use \"git reset HEAD^\" to remove the top commit)}" > > > > That message is a bad idea. Doing a mixed mode reset will also > > reset the index, causing the user to lose any changes that had > > already been staged. This may actually be difficult for him/her to > > recover from if they have used `git add -i` or git-gui to stage only > > certain hunks of files, or if their working tree has been further > > modified after the commit but they want to go back and amend the > > message only of the prior commit. > > Would "git reset --soft HEAD^" advice be better than first one? > Could you suggest a better message, please? Hmm. I think you want something like this perhaps? if test "$tree" = "$current_tree" then if test z$amend = zt then echo >&2 "nothing to amend (use \"git reset --soft HEAD^\" to discard last commit)" else echo >&2 "nothing to commit" fi fi Because there's this weird trick where you can amend the last commit using a dirty index and in the process maybe cause the last commit to have the same tree as his parent. In such a case you would want to discard the last commit instead of amending it. But I have to also wonder, aside from the sick amend case I just talked about, how does one get to this part of git-commit.sh with nothing to commit? -- Shawn. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html