Merge branch 'mr/rebase-i-customize-insn-sheet'
"git rebase -i"'s list of todo is made configurable. * mr/rebase-i-customize-insn-sheet: git-rebase--interactive.sh: add config option for custom instruction formatmaint
commit
9f56db7caf
|
@ -2161,6 +2161,11 @@ rebase.autoStash::
|
||||||
successful rebase might result in non-trivial conflicts.
|
successful rebase might result in non-trivial conflicts.
|
||||||
Defaults to false.
|
Defaults to false.
|
||||||
|
|
||||||
|
rebase.instructionFormat
|
||||||
|
A format string, as specified in linkgit:git-log[1], to be used for
|
||||||
|
the instruction list during an interactive rebase. The format will automatically
|
||||||
|
have the long commit hash prepended to the format.
|
||||||
|
|
||||||
receive.advertiseAtomic::
|
receive.advertiseAtomic::
|
||||||
By default, git-receive-pack will advertise the atomic push
|
By default, git-receive-pack will advertise the atomic push
|
||||||
capability to its clients. If you don't want to this capability
|
capability to its clients. If you don't want to this capability
|
||||||
|
|
|
@ -213,6 +213,9 @@ rebase.autoSquash::
|
||||||
rebase.autoStash::
|
rebase.autoStash::
|
||||||
If set to true enable '--autostash' option by default.
|
If set to true enable '--autostash' option by default.
|
||||||
|
|
||||||
|
rebase.instructionFormat::
|
||||||
|
Custom commit list format to use during an '--interactive' rebase.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
--onto <newbase>::
|
--onto <newbase>::
|
||||||
|
@ -359,6 +362,10 @@ default is `--no-fork-point`, otherwise the default is `--fork-point`.
|
||||||
Make a list of the commits which are about to be rebased. Let the
|
Make a list of the commits which are about to be rebased. Let the
|
||||||
user edit that list before rebasing. This mode can also be used to
|
user edit that list before rebasing. This mode can also be used to
|
||||||
split commits (see SPLITTING COMMITS below).
|
split commits (see SPLITTING COMMITS below).
|
||||||
|
+
|
||||||
|
The commit list format can be changed by setting the configuration option
|
||||||
|
rebase.instructionFormat. A customized instruction format will automatically
|
||||||
|
have the long commit hash prepended to the format.
|
||||||
|
|
||||||
-p::
|
-p::
|
||||||
--preserve-merges::
|
--preserve-merges::
|
||||||
|
|
|
@ -740,10 +740,15 @@ collapse_todo_ids() {
|
||||||
# "pick sha1 fixup!/squash! msg" appears in it so that the latter
|
# "pick sha1 fixup!/squash! msg" appears in it so that the latter
|
||||||
# comes immediately after the former, and change "pick" to
|
# comes immediately after the former, and change "pick" to
|
||||||
# "fixup"/"squash".
|
# "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 () {
|
rearrange_squash () {
|
||||||
# extract fixup!/squash! lines and resolve any referenced sha1's
|
# extract fixup!/squash! lines and resolve any referenced sha1's
|
||||||
while read -r pick sha1 message
|
while read -r pick sha1 message
|
||||||
do
|
do
|
||||||
|
test -z "${format}" || message=$(git log -n 1 --format="%s" ${sha1})
|
||||||
case "$message" in
|
case "$message" in
|
||||||
"squash! "*|"fixup! "*)
|
"squash! "*|"fixup! "*)
|
||||||
action="${message%%!*}"
|
action="${message%%!*}"
|
||||||
|
@ -785,6 +790,7 @@ rearrange_squash () {
|
||||||
*" $sha1 "*) continue ;;
|
*" $sha1 "*) continue ;;
|
||||||
esac
|
esac
|
||||||
printf '%s\n' "$pick $sha1 $message"
|
printf '%s\n' "$pick $sha1 $message"
|
||||||
|
test -z "${format}" || message=$(git log -n 1 --format="%s" ${sha1})
|
||||||
used="$used$sha1 "
|
used="$used$sha1 "
|
||||||
while read -r squash action msg_prefix msg_content
|
while read -r squash action msg_prefix msg_content
|
||||||
do
|
do
|
||||||
|
@ -802,8 +808,13 @@ rearrange_squash () {
|
||||||
case "$message" in "$msg_content"*) emit=1;; esac ;;
|
case "$message" in "$msg_content"*) emit=1;; esac ;;
|
||||||
esac
|
esac
|
||||||
if test $emit = 1; then
|
if test $emit = 1; then
|
||||||
real_prefix=$(echo "$msg_prefix" | sed "s/,/! /g")
|
if test -n "${format}"
|
||||||
printf '%s\n' "$action $squash ${real_prefix}$msg_content"
|
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 "
|
used="$used$squash "
|
||||||
fi
|
fi
|
||||||
done <"$1.sq"
|
done <"$1.sq"
|
||||||
|
@ -981,7 +992,10 @@ else
|
||||||
revisions=$onto...$orig_head
|
revisions=$onto...$orig_head
|
||||||
shortrevisions=$shorthead
|
shortrevisions=$shorthead
|
||||||
fi
|
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} | \
|
$revisions ${restrict_revision+^$restrict_revision} | \
|
||||||
sed -n "s/^>//p" |
|
sed -n "s/^>//p" |
|
||||||
while read -r sha1 rest
|
while read -r sha1 rest
|
||||||
|
|
|
@ -250,4 +250,25 @@ test_expect_success 'squash! fixup!' '
|
||||||
test_auto_fixup_fixup squash fixup
|
test_auto_fixup_fixup squash fixup
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'autosquash with custom inst format' '
|
||||||
|
git reset --hard base &&
|
||||||
|
git config --add rebase.instructionFormat "[%an @ %ar] %s" &&
|
||||||
|
echo 2 >file1 &&
|
||||||
|
git add -u &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m "squash! $(git rev-parse --short HEAD^)" &&
|
||||||
|
echo 1 >file1 &&
|
||||||
|
git add -u &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m "squash! $(git log -n 1 --format=%s HEAD~2)" &&
|
||||||
|
git tag final-squash-instFmt &&
|
||||||
|
test_tick &&
|
||||||
|
git rebase --autosquash -i HEAD~4 &&
|
||||||
|
git log --oneline >actual &&
|
||||||
|
test_line_count = 3 actual &&
|
||||||
|
git diff --exit-code final-squash-instFmt &&
|
||||||
|
test 1 = "$(git cat-file blob HEAD^:file1)" &&
|
||||||
|
test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue