1
0
mirror of https://github.com/git/git.git synced 2024-09-28 18:32:37 +02:00

git-am: do not allow empty commits by mistake.

Running "git-am --resolved" without doing anything can create an empty
commit. Prevent it.

Thanks for Eric W. Biederman for spotting this.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2006-02-23 22:14:47 -08:00
parent 183bdb2ccc
commit 6d28644d69

@ -300,7 +300,7 @@ do
} >"$dotest/final-commit" } >"$dotest/final-commit"
;; ;;
*) *)
case "$resolved,$interactive" in case "$resolved$interactive" in
tt) tt)
# This is used only for interactive view option. # This is used only for interactive view option.
git-diff-index -p --cached HEAD >"$dotest/patch" git-diff-index -p --cached HEAD >"$dotest/patch"
@ -364,6 +364,12 @@ do
# trust what the user has in the index file and the # trust what the user has in the index file and the
# working tree. # working tree.
resolved= resolved=
changed="$(git-diff-index --cached --name-only HEAD)"
if test '' = "$changed"
then
echo "No changes - did you forget update-index?"
stop_here $this
fi
apply_status=0 apply_status=0
;; ;;
esac esac
@ -374,7 +380,7 @@ do
then then
# Applying the patch to an earlier tree and merging the # Applying the patch to an earlier tree and merging the
# result may have produced the same tree as ours. # result may have produced the same tree as ours.
changed="$(git-diff-index --cached --name-only -z HEAD)" changed="$(git-diff-index --cached --name-only HEAD)"
if test '' = "$changed" if test '' = "$changed"
then then
echo No changes -- Patch already applied. echo No changes -- Patch already applied.