On Tue, Jul 10, 2012 at 01:14:32PM -0700, Junio C Hamano wrote:
I do not think the combination with --amend, --only and no paths
ever worked. We rejected such a combination before 6a74642c5, which
merely made us to accept the combination but I do not think the
commit did anything to re-read the tree from the HEAD being amended
to the index.
Something like this, but I haven't thought about what other things
it may break.
Our emails just crossed. I came to the exact same conclusion, and just
wrote almost the exact same patch.
- if (!pathspec || !*pathspec) {
+ if (!(only && amend) && (!pathspec || !*pathspec)) {
It is sufficient to check only "only" in the first part of your
conditional, as we disallow empty pathspecs with "-o". And even if we
didn't disallow it, this would do the right thing by trying to create a
partial commit with no changes (which would fail, of course, but is the
only sane thing for the prepare_index function to do; certainly doing an
as-is commit is simply wrong).
-Peff