git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] git-commit: Disallow unchanged tree in non-merge mode
@ 2007-09-05 23:49 Dmitry V. Levin
  2007-09-06  2:25 ` Shawn O. Pearce
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry V. Levin @ 2007-09-05 23:49 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

Do not commit an unchanged tree in non-merge mode.

While regular mode is already handled by git-runstatus, this cheap check
allows to avoid costly git-runstatus later.  Also, amend mode needs
special attention, because git-runstatus return value is ignored.
The idea is that amend should not commit an unchanged tree,
one should just remove the top commit using git-reset instead.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 git-commit.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/git-commit.sh b/git-commit.sh
index 1d04f1f..800f96c 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -629,6 +629,16 @@ then
 		tree=$(GIT_INDEX_FILE="$TMP_INDEX" git write-tree) &&
 		rm -f "$TMP_INDEX"
 	fi &&
+	if test -n "$current" -a ! -f "$GIT_DIR/MERGE_HEAD"
+	then
+		current_tree="$(git cat-file commit "$current${amend:+^}" 2>/dev/null |
+				sed -e '/^tree \+/!d' -e 's///' -e q)"
+		if test "$tree" = "$current_tree"
+		then
+			echo >&2 "nothing to commit${amend:+ (use \"git reset HEAD^\" to remove the top commit)}"
+			false
+		fi
+	fi &&
 	commit=$(git commit-tree $tree $PARENTS <"$GIT_DIR/COMMIT_MSG") &&
 	rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
 	git update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" &&
-- 
ldv

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-09-14 19:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
     [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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).