rebase -i: Change function make_squash_message into update_squash_message
Alter the file $SQUASH_MSG in place rather than outputting the new message then juggling it around. Change the function name accordingly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Jan 14, 2010 at 06:54 UTC
bde1a68624c59d891ec02fda473c3aef98ec9358
1 file changed
+20
-15
git-rebase--interactive.sh
+20
-15
@@ -358,21 +358,26 @@ nth_string () {
358
esac
359
}
360
361
-make_squash_message () {
361
+update_squash_message () {
362
if test -f "$SQUASH_MSG"; then
363
+ mv "$SQUASH_MSG" "$SQUASH_MSG".bak || exit
364
COUNT=$(($(sed -n \
365
-e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
365
- -e "q" < "$SQUASH_MSG")+1))
366
- echo "# This is a combination of $COUNT commits."
367
- sed -e 1d -e '2,/^./{
368
- /^$/d
369
- }' <"$SQUASH_MSG"
366
+ -e "q" < "$SQUASH_MSG".bak)+1))
367
+ {
368
+ echo "# This is a combination of $COUNT commits."
369
+ sed -e 1d -e '2,/^./{
370
+ /^$/d
371
+ }' <"$SQUASH_MSG".bak
372
+ } >$SQUASH_MSG
373
else
374
COUNT=2
372
- echo "# This is a combination of 2 commits."
373
- echo "# The first commit's message is:"
374
- echo
375
- commit_message HEAD
375
+ {
376
+ echo "# This is a combination of 2 commits."
377
+ echo "# The first commit's message is:"
378
+ echo
379
+ commit_message HEAD
380
+ } >$SQUASH_MSG
381
fi
382
case $1 in
383
squash)
@@ -387,7 +392,7 @@ make_squash_message () {
392
echo
393
commit_message $2 | sed -e 's/^/# /'
394
;;
390
- esac
395
+ esac >>$SQUASH_MSG
396
}
397
398
peek_next_command () {
@@ -450,7 +455,7 @@ do_next () {
455
die "Cannot '$squash_style' without a previous commit"
456
457
mark_action_done
453
- make_squash_message $squash_style $sha1 > "$MSG"
458
+ update_squash_message $squash_style $sha1
459
failed=f
460
author_script=$(get_author_ident_from_commit HEAD)
461
echo "$author_script" > "$AUTHOR_SCRIPT"
@@ -460,16 +465,16 @@ do_next () {
465
case "$(peek_next_command)" in
466
squash|s|fixup|f)
467
USE_OUTPUT=output
468
+ cp "$SQUASH_MSG" "$MSG" || exit
469
MSG_OPT=-F
470
EDIT_OR_FILE="$MSG"
465
- cp "$MSG" "$SQUASH_MSG"
471
;;
472
*)
473
USE_OUTPUT=
474
MSG_OPT=
475
EDIT_OR_FILE=-e
471
- rm -f "$SQUASH_MSG" || exit
472
- cp "$MSG" "$GIT_DIR"/SQUASH_MSG
476
+ cp "$SQUASH_MSG" "$MSG" || exit
477
+ mv "$SQUASH_MSG" "$GIT_DIR"/SQUASH_MSG || exit
478
rm -f "$GIT_DIR"/MERGE_MSG || exit
479
;;
480
esac