2 # TopGit rebase command
3 # (C) 2015 Kyle J. McKay <mackyle@gmail.com>
6 USAGE
="Usage: ${tgname:-tg} [...] rebase (-m | --merge) [<git-rebase-arg>...]"
8 case "$1" in -h|
--help)
20 --skip|
--continue|
--abort|
--edit-todo)
25 if [ -n "$optcontinue" ]; then
26 if [ -n "$git_dir" ] && [ -d "$git_dir" ] && ! [ -d "$git_dir/rebase-merge" ]; then
31 if [ -z "$optmerge" -a -z "$optcontinue" ]; then
33 ${tgname:-tg} rebase is intended as a drop-in replacement for git rebase -m.
34 Either add the -m (or --merge) option to the command line or use git rebase
35 directly. When using rebase to flatten history the merge mode is superior.
40 if [ -z "$optcontinue" ]; then
41 rerereon
="$(git config --get --bool rerere.enabled 2>/dev/null)" ||
:
42 [ "$rerereon" = "true" ] ||
43 warn
"rerere.enabled is false, automatic --continue not possible"
46 [ "$*" = "--abort" ] || ensure_ident_available
47 continuemsg
='"git rebase --continue"'
49 newhead
="$(git rev-parse --verify --quiet HEAD --)" ||
:
55 msg
="$(git -c rerere.autoupdate=true rebase "$@
" 3>&2 2>&1 1>&3 3>&-)" || err
=$?
56 case "$msg" in *"$continuemsg"*) hascontinuemsg
=1; esac
57 newhead
="$(git rev-parse --verify --quiet HEAD --)" ||
:
58 [ "$newhead" != "$lasthead" ] || hascontinuemsg
=
59 msg
="$(printf '%s\n' "$msg" | sed -e 's~git rebase ~'"$tgdisplay"' rebase ~g')"
62 if [ -n "$hascontinuemsg" ] && [ $
(git ls-files
--unmerged |
wc -l) -eq 0 ]; then
63 while IFS
= read -r line
; do case "$line" in
64 "Staged "*|
"Resolved "*|
"Recorded "*)
65 printf '%s\n' "$line";;
77 [ -z "$msg" ] ||
printf '%s\n' "$msg" >&2