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>
Junio C Hamano committed
Feb 23, 2006 at 22:14 UTC
6d28644d691fa3967d24d988d51d863f22bbcc63
1 file changed
+8
-2
git-am.sh
+8
-2
@@ -300,7 +300,7 @@ do
300
} >"$dotest/final-commit"
301
;;
302
*)
303
- case "$resolved,$interactive" in
303
+ case "$resolved$interactive" in
304
tt)
305
# This is used only for interactive view option.
306
git-diff-index -p --cached HEAD >"$dotest/patch"
@@ -364,6 +364,12 @@ do
364
# trust what the user has in the index file and the
365
# working tree.
366
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
373
apply_status=0
374
;;
375
esac
@@ -374,7 +380,7 @@ do
380
then
381
# Applying the patch to an earlier tree and merging the
382
# 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)"
384
if test '' = "$changed"
385
then
386
echo No changes -- Patch already applied.