Junio C Hamano  committed 6a74642

git-commit --amend: two fixes.

When running "git commit --amend" only to fix the commit log
message without any content change, we mistakenly showed the
git-status output that says "nothing to commit" without
commenting it out.

If you have already run update-index but you want to amend the
top commit, "git commit --amend --only" without any paths should
have worked, because --only means "starting from the base
commit, update-index these paths only to prepare the index to
commit, and perform the commit". However, we refused -o without

Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits 61c2bcb

Comments (0)

Files changed (2)


 	case "$committable" in
-	    echo "nothing to commit"
-	    exit 1
+		case "$amend" in
+		t)
+			echo "# No changes" ;;
+		*)
+			echo "nothing to commit" ;;
+		esac
+		exit 1 ;;
 	exit 0
   die "Only one of -c/-C/-F/-m can be used." ;;
-case "$#,$also$only" in
+case "$#,$also,$only,$amend" in
   die "Only one of --include/--only can be used." ;;
+0,t,,* | 0,,t,)
   die "No paths with --include/--only does not make sense." ;;
+  only_include_assumed="# Clever... amending the last one with dirty index." ;;
   only_include_assumed="# Explicit paths specified without -i nor -o; assuming --only paths..."

File t/

 git commit -m 'Merged "mybranch" changes.' -i hello
 cat > show-branch.expect << EOF
 * [master] Merged "mybranch" changes.
  ! [mybranch] Some work.