Unfortunately, I do not think it is possible.
The only way you can customize the rebase output is through rebase.instructionFormat
configuration, like this:
git config rebase.instructionFormat "..."
I tried with the option %B
to return the subject with the body too, but the rebase operation fails with the following error:
error: invalid line 5: second line
error: invalid line 7: third line
error: invalid line 8: forth line
BUG: builtin/rebase.c:353: unusable todo list
Aborted (core dumped)
it seems like git considers the lines after the first one as executable code.
I checked on the git log
documentation, but among the --format
options I did not see anything that could replace the line feed with something else, or simply ignore it.
At this point, you could clone your repo, run git filter-branch
to replace line feeds with spaces for example, and eventually run git rebase -i
.
git filter-branch --msg-filter "xargs echo"
The interactive rebase does not consider the "third column", basically what you choose to log for a certain commit, so at the end you could copy and paste the output of the interactive rebase on the second repo (the one you filter-branch
ed) inside the editor of your main repo.
Anyway, I just found a question similar to yours.
EDIT:
if you want another tool to take care of formatting the new commit message you can always create a script, like this one to replace line feed with \n
#!/bin/bash
cat | sed ':a;N;$!ba;s/\n/\\n/g'
and call it inside --msg-filter
option
git filter-branch --msg-filter "cat | $(pwd)/script.sh"
EDIT: I almost forgot that filter-branch
recreates each commit that matches with the filter specified, so, before editing you should replace the commits column of the interactive rebase output in the cloned repo with the real commits in the main repo. It is getting more tedious than I imagined. Let's go back to simple things: we can simulate an interactive rebase without actually calling it. The script can be improved but I think the direction is the right one:
#!/bin/bash
for commit in $(git rev-list $1..HEAD | tac)
do
git log -n 1 $commit --format="pick %h %B" | xargs echo
done;
you call it like this
./script HEAD~3
and you obtain the interactive rebase output (kind of, without comments)
pick 483ac92 first commit
pick bb739b7 second commit
pick 59f2bf0 very long commit with multiline