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 paths. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 20, 2006 at 01:20 UTC
6a74642c500118164ec331da93ef29b1163301bc
2 files changed
+16
-7
git-commit.sh
+14
-7
@@ -167,8 +167,13 @@ run_status () {
167
fi
168
case "$committable" in
169
0)
170
- echo "nothing to commit"
171
- exit 1
170
+ case "$amend" in
171
+ t)
172
+ echo "# No changes" ;;
173
+ *)
174
+ echo "nothing to commit" ;;
175
+ esac
176
+ exit 1 ;;
177
esac
178
exit 0
179
)
@@ -365,14 +370,16 @@ tt*)
370
die "Only one of -c/-C/-F/-m can be used." ;;
371
esac
372
368
-case "$#,$also$only" in
369
-*,tt)
373
+case "$#,$also,$only,$amend" in
374
+*,t,t,*)
375
die "Only one of --include/--only can be used." ;;
371
-0,t)
376
+0,t,,* | 0,,t,)
377
die "No paths with --include/--only does not make sense." ;;
373
-0,)
378
+0,,t,t)
379
+ only_include_assumed="# Clever... amending the last one with dirty index." ;;
380
+0,,,*)
381
;;
375
-*,)
382
+*,,,*)
383
only_include_assumed="# Explicit paths specified without -i nor -o; assuming --only paths..."
384
also=
385
;;
t/t1200-tutorial.sh
+2
@@ -114,6 +114,8 @@ EOF
114
115
git commit -m 'Merged "mybranch" changes.' -i hello
116
117
+test_done
118
+
119
cat > show-branch.expect << EOF
120
* [master] Merged "mybranch" changes.
121
! [mybranch] Some work.