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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| David Miller | Re: Slow DOWN, please!!! |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Heiko Carstens | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
| Jan Engelhardt | Re: iptables very slow after commit 784544739a25c30637397ace5489eeb6e15d7d49 |
