Skip to content

Commit 6d5129a

Browse files
author
Junio C Hamano
committed
Merge branch 'fix' into maint
* fix: git-am: do not allow empty commits by mistake.
2 parents 7bd1527 + 6d28644 commit 6d5129a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

git-am.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ do
300300
} >"$dotest/final-commit"
301301
;;
302302
*)
303-
case "$resolved,$interactive" in
303+
case "$resolved$interactive" in
304304
tt)
305305
# This is used only for interactive view option.
306306
git-diff-index -p --cached HEAD >"$dotest/patch"
@@ -364,6 +364,12 @@ do
364364
# trust what the user has in the index file and the
365365
# working tree.
366366
resolved=
367+
changed="$(git-diff-index --cached --name-only HEAD)"
368+
if test '' = "$changed"
369+
then
370+
echo "No changes - did you forget update-index?"
371+
stop_here $this
372+
fi
367373
apply_status=0
368374
;;
369375
esac
@@ -374,7 +380,7 @@ do
374380
then
375381
# Applying the patch to an earlier tree and merging the
376382
# result may have produced the same tree as ours.
377-
changed="$(git-diff-index --cached --name-only -z HEAD)"
383+
changed="$(git-diff-index --cached --name-only HEAD)"
378384
if test '' = "$changed"
379385
then
380386
echo No changes -- Patch already applied.

0 commit comments

Comments
 (0)