rebase -i: Extract a function "commit_message"
...instead of repeating the same short but slightly obscure blob of code in several places. 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
ee0a4afbe2baeec2bfdf3d8e7abc77f24294298d
1 file changed
+10
-5
git-rebase--interactive.sh
+10
-5
@@ -118,6 +118,11 @@ output () {
118
esac
119
}
120
121
+# Output the commit message for the specified commit.
122
+commit_message () {
123
+ git cat-file commit "$1" | sed "1,/^$/d"
124
+}
125
+
126
run_pre_rebase_hook () {
127
if test -z "$OK_TO_SKIP_PRE_REBASE" &&
128
test -x "$GIT_DIR/hooks/pre-rebase"
@@ -178,7 +183,7 @@ make_patch () {
183
;;
184
esac > "$DOTEST"/patch
185
test -f "$MSG" ||
181
- git cat-file commit "$1" | sed "1,/^$/d" > "$MSG"
186
+ commit_message "$1" > "$MSG"
187
test -f "$AUTHOR_SCRIPT" ||
188
get_author_ident_from_commit "$1" > "$AUTHOR_SCRIPT"
189
}
@@ -316,7 +321,7 @@ pick_one_preserving_merges () {
321
# redo merge
322
author_script=$(get_author_ident_from_commit $sha1)
323
eval "$author_script"
319
- msg="$(git cat-file commit $sha1 | sed -e '1,/^$/d')"
324
+ msg="$(commit_message $sha1)"
325
# No point in merging the first parent, that's HEAD
326
new_parents=${new_parents# $first_parent}
327
if ! GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
@@ -361,20 +366,20 @@ make_squash_message () {
366
echo "# This is a combination of 2 commits."
367
echo "# The first commit's message is:"
368
echo
364
- git cat-file commit HEAD | sed -e '1,/^$/d'
369
+ commit_message HEAD
370
fi
371
case $1 in
372
squash)
373
echo
374
echo "# This is the $(nth_string $COUNT) commit message:"
375
echo
371
- git cat-file commit $2 | sed -e '1,/^$/d'
376
+ commit_message $2
377
;;
378
fixup)
379
echo
380
echo "# The $(nth_string $COUNT) commit message will be skipped:"
381
echo
377
- git cat-file commit $2 | sed -e '1,/^$/d' -e 's/^/# /'
382
+ commit_message $2 | sed -e 's/^/# /'
383
;;
384
esac
385
}