3 # Provides a convenient alias for "git rebase -i --autosquash --keep-root"
4 # on gits that have it, and a replacement on gits that don't.
10 if test "$PARENT" = ""; then
11 echo "You must specify the parent branch."
15 # Can we use git rebase --keep-base? Detect the git version to find out.
17 if test "$(echo "$GITVER"|cut -d ' ' -f 1-2)" = "git version"; then
18 # --keep-base was added in git 2.24. Detect if we have that version.
19 GITVER
=$
(echo "$GITVER" | cut
-d ' ' -f 3)
20 major
=$
(echo "$GITVER" | cut
-d .
-f 1)
21 minor
=$
(echo "$GITVER" | cut
-d .
-f 2)
22 if test "$major" -lt 2; then
24 elif test "$major" -eq 2 && test "$minor" -lt 24; then
30 # This isn't a git that reports its version in a way recognize; assume that
31 # --keep-base will work
35 if test "$USE_KEEP_BASE" = "1" ; then
36 exec git rebase
-i --autosquash --keep-base "${PARENT}"
38 REV
=$
(git log
--reverse --format='%H' "${PARENT}..HEAD" |
head -1)
40 if test "${REV}" = ""; then
41 echo "No changes here since ${PARENT}"
45 exec git rebase
-i --autosquash "${REV}^"