Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15

Re: "git commit --amend --only --" nevertheless commits staged changes

From: Jeff King <hidden>
Date: 2016-06-15 22:54:14

Possibly related (same subject, not in this thread)

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help