rebase -i: Simplify commit counting for generated commit messages
Read the old count from the first line of the old commit message rather than counting the number of commit message blocks in the file. This is simpler, faster, and more robust (e.g., it cannot be confused by strange commit message contents). 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
f99e269c44a7f07699a92c7e31d31ed93dafb409
1 file changed
+3
-8
git-rebase--interactive.sh
+3
-8
@@ -349,11 +349,9 @@ nth_string () {
349
350
make_squash_message () {
351
if test -f "$SQUASH_MSG"; then
352
- # We want to be careful about matching only the commit
353
- # message comment lines generated by this function.
354
- # "[snrt][tdh]" matches the nth_string endings.
355
- COUNT=$(($(sed -n "s/^# Th[^0-9]*\([1-9][0-9]*\)[snrt][tdh] commit message.*:/\1/p" \
356
- < "$SQUASH_MSG" | sed -ne '$p')+1))
352
+ COUNT=$(($(sed -n \
353
+ -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
354
+ -e "q" < "$SQUASH_MSG")+1))
355
echo "# This is a combination of $COUNT commits."
356
sed -e 1d -e '2,/^./{
357
/^$/d
@@ -376,9 +374,6 @@ make_squash_message () {
374
echo
375
echo "# The $(nth_string $COUNT) commit message will be skipped:"
376
echo
379
- # Comment the lines of the commit message out using
380
- # "# " rather than "# " to make them less likely to
381
- # confuse the sed regexp above.
377
git cat-file commit $2 | sed -e '1,/^$/d' -e 's/^/# /'
378
;;
379
esac