All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/2] git-commit: Disallow unchanged tree in non-merge mode
Date: Thu, 6 Sep 2007 14:16:48 +0400	[thread overview]
Message-ID: <20070906101648.GD6665@basalt.office.altlinux.org> (raw)
In-Reply-To: <20070906022539.GG18160@spearce.org>

[-- Attachment #1: Type: text/plain, Size: 2474 bytes --]

On Wed, Sep 05, 2007 at 10:25:39PM -0400, Shawn O. Pearce wrote:
> "Dmitry V. Levin" <ldv@altlinux.org> wrote:
> > Do not commit an unchanged tree in non-merge mode.
> 
> A laudable goal.  git-gui also does this.  Turns out the other
> checks within git-gui prevent the user from ever getting that far.
> I probably should remove the empty tree check as it costs CPU time
> to get the old tree.  But I'd rather have the safety check.
>  
> > The idea is that amend should not commit an unchanged tree,
> > one should just remove the top commit using git-reset instead.
> 
> 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.

> Or adding additional detail.

If that "additional" detail just undoes the latest commit, why should
"git commit --amend" welcome such thing?  I did not get your pint here.

> Forcing the user to do
> a `git reset --soft HEAD^ && git commit --amend` just because
> you don't want git-commit to make an "empty commit" (which it
> doesn't usually like to do now anyway!) is a major step back
> in functionality.

I suppose that helping users to avoid doing really stupid things
does not look as a major step back in functionality, just otherwise.

> > +		current_tree="$(git cat-file commit "$current${amend:+^}" 2>/dev/null |
> > +				sed -e '/^tree \+/!d' -e 's///' -e q)"
> 
> The better way to get the old tree would be this:
> 
> 		current_tree="$(git rev-parse "$current${amend:+^}^{tree}" 2>/dev/null
> 
> as it avoids the tool from needing to know about the internal
> representation of a commit object.  It also avoids an entire
> fork+exec of a sed process.

Agreed.

> > +		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?


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-09-06 10:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-05 23:49 [PATCH 1/2] git-commit: Disallow unchanged tree in non-merge mode Dmitry V. Levin
2007-09-06  2:25 ` Shawn O. Pearce
2007-09-06 10:16   ` Dmitry V. Levin [this message]
     [not found]     ` <20070909044648.GH18160@spearce.org>
     [not found]       ` <7vir6fjmuv.fsf@gitster.siamese.dyndns.org>
     [not found]         ` <20070913035137.GM3099@spearce.org>
     [not found]           ` <7vr6l2gxyw.fsf@gitster.siamese.dyndns.org>
     [not found]             ` <20070914000108.GE3619@basalt.office.altlinux.org>
     [not found]               ` <7vr6l2f6k1.fsf@gitster.siamese.dyndns.org>
     [not found]                 ` <alpine.LFD.0.999.0709131850060.16478@woody.linux-foundation.org>
     [not found]                   ` <20070914024303.GH3619@basalt.office.altlinux.org>
     [not found]                     ` <alpine.LFD.0.999.0709132123570.16478@woody.linux-foundation.org>
2007-09-14 17:14                       ` Linus Torvalds
2007-09-14 17:17                         ` [PATCH 1/2] Fix "git diff" setup code Linus Torvalds
2007-09-14 17:39                           ` [PATCH 2/2] Fix the rename detection limit checking Linus Torvalds
2007-09-14 18:44                             ` Linus Torvalds
2007-09-14 18:49                               ` Linus Torvalds
2007-09-14 18:19                           ` [PATCH 1/2] Fix "git diff" setup code Junio C Hamano
2007-09-14 18:30                             ` Linus Torvalds
2007-09-14 19:11                               ` Junio C Hamano
2007-09-14 19:46                                 ` Linus Torvalds
     [not found]                       ` <20070914050410.GA11402@coredump.intra.peff.net>
     [not found]                         ` <alpine.LFD.0.999.0709132215250.16478@woody.linux-foundation.org>
2007-09-14 18:24                           ` [PATCH 1/2] git-commit: Disallow unchanged tree in non-merge mode Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070906101648.GD6665@basalt.office.altlinux.org \
    --to=ldv@altlinux.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.