aboutsummaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorMichael Rappazzo <rappazzo@gmail.com>2015-06-13 12:26:58 -0400
committerJunio C Hamano <gitster@pobox.com>2015-06-15 11:42:58 -0700
commit16cf51c7a2e82f27577bb1bdcdc013c34815803e (patch)
tree3401b5762913fc10a6297ec6ca4511f7df4e12b0 /git-rebase--interactive.sh
parent7974889a053574e449b55ca543a486e38e74864f (diff)
downloadgit-16cf51c7a2e82f27577bb1bdcdc013c34815803e.tar.gz
git-16cf51c7a2e82f27577bb1bdcdc013c34815803e.tar.xz
git-rebase--interactive.sh: add config option for custom instruction format
A config option 'rebase.instructionFormat' can override the default 'oneline' format of the rebase instruction list. Since the list is parsed using the left, right or boundary mark plus the sha1, they are prepended to the instruction format. Signed-off-by: Michael Rappazzo <rappazzo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh20
1 files changed, 17 insertions, 3 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index dc3133f68..b2da100ac 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -740,10 +740,15 @@ collapse_todo_ids() {
# "pick sha1 fixup!/squash! msg" appears in it so that the latter
# comes immediately after the former, and change "pick" to
# "fixup"/"squash".
+#
+# Note that if the config has specified a custom instruction format
+# each log message will be re-retrieved in order to normalize the
+# autosquash arrangement
rearrange_squash () {
# extract fixup!/squash! lines and resolve any referenced sha1's
while read -r pick sha1 message
do
+ test -z "${format}" || message=$(git log -n 1 --format="%s" ${sha1})
case "$message" in
"squash! "*|"fixup! "*)
action="${message%%!*}"
@@ -785,6 +790,7 @@ rearrange_squash () {
*" $sha1 "*) continue ;;
esac
printf '%s\n' "$pick $sha1 $message"
+ test -z "${format}" || message=$(git log -n 1 --format="%s" ${sha1})
used="$used$sha1 "
while read -r squash action msg_prefix msg_content
do
@@ -802,8 +808,13 @@ rearrange_squash () {
case "$message" in "$msg_content"*) emit=1;; esac ;;
esac
if test $emit = 1; then
- real_prefix=$(echo "$msg_prefix" | sed "s/,/! /g")
- printf '%s\n' "$action $squash ${real_prefix}$msg_content"
+ if test -n "${format}"
+ then
+ msg_content=$(git log -n 1 --format="${format}" ${squash})
+ else
+ msg_content="$(echo "$msg_prefix" | sed "s/,/! /g")$msg_content"
+ fi
+ printf '%s\n' "$action $squash $msg_content"
used="$used$squash "
fi
done <"$1.sq"
@@ -977,7 +988,10 @@ else
revisions=$onto...$orig_head
shortrevisions=$shorthead
fi
-git rev-list $merges_option --pretty=oneline --reverse --left-right --topo-order \
+format=$(git config --get rebase.instructionFormat)
+# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse
+git rev-list $merges_option --format="%m%H ${format:-%s}" \
+ --reverse --left-right --topo-order \
$revisions ${restrict_revision+^$restrict_revision} | \
sed -n "s/^>//p" |
while read -r sha1 rest