git config --global sequence.editor rebase-editor.sh
Created
July 22, 2024 19:57
-
-
Save AnrDaemon/318d233f9fea65e80159f9ebd774d91b to your computer and use it in GitHub Desktop.
Git rebase-editor with files list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
_tmp="$(mktemp --tmpdir -- git-rebase-todo.XXXXXX )" | |
_editor="$(git config core.editor)" | |
cp "$1" "$_tmp" | |
{ | |
while read -r _ cid header; do | |
if [ "$_" = "pick" ]; then | |
printf "pick %s %s\n" "$cid" "$header" | |
git diff --name-only -z "$cid^!" | xargs -0 printf "# %s\n" #sed -Ee '/^$/d; s/^/# /;' | |
else | |
echo "$_${cid:+ $cid}${header:+ $header}" | |
fi | |
done | |
} > "$1" < "$_tmp" | |
rm "$_tmp" | |
"${_editor?-${GIT_EDITOR:?Please define GIT_EDITOR env.var.}}" "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment