File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ die_with_patch () {
6060 die " $2 "
6161}
6262
63+ die_abort () {
64+ rm -rf " $DOTEST "
65+ die " $1 "
66+ }
67+
6368pick_one () {
6469 case " $1 " in -n) sha1=$2 ;; * ) sha1=$1 ;; esac
6570 git rev-parse --verify $sha1 || die " Invalid commit name: $sha1 "
212217 -C* )
213218 die " Interactive rebase uses merge, so $1 does not make sense"
214219 ;;
215- -v)
220+ -v|--verbose )
216221 VERBOSE=t
217222 ;;
218223 -i|--interactive)
264269 echo $ONTO > " $DOTEST " /onto
265270 test t = " $VERBOSE " && : > " $DOTEST " /verbose
266271
272+ SHORTUPSTREAM=$( git rev-parse --short $UPSTREAM )
273+ SHORTHEAD=$( git rev-parse --short $HEAD )
274+ SHORTONTO=$( git rev-parse --short $ONTO )
267275 cat > " $TODO " << EOF
268- # Rebasing $UPSTREAM ..$HEAD onto $ONTO
276+ # Rebasing $SHORTUPSTREAM ..$SHORTHEAD onto $SHORTONTO
269277#
270278# Commands:
271279# pick = use commit
@@ -277,13 +285,16 @@ EOF
277285 sed " s/^/pick /" >> " $TODO "
278286
279287 test -z " $( grep -ve ' ^$' -e ' ^#' < $TODO ) " &&
280- die " Nothing to do"
288+ die_abort " Nothing to do"
281289
282290 cp " $TODO " " $TODO " .backup
283291 ${VISUAL:- ${EDITOR:- vi} } " $TODO " ||
284292 die " Could not execute editor"
285293
286- git reset --hard $ONTO && do_rest
294+ test -z " $( grep -ve ' ^$' -e ' ^#' < $TODO ) " &&
295+ die_abort " Nothing to do"
296+
297+ git checkout $ONTO && do_rest
287298 esac
288299 shift
289300done
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ test_expect_success 'abort' '
140140test_expect_success ' retain authorship' '
141141 echo A > file7 &&
142142 git add file7 &&
143+ test_tick &&
143144 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
144145 git tag twerp &&
145146 git rebase -i --onto master HEAD^ &&
@@ -149,6 +150,7 @@ test_expect_success 'retain authorship' '
149150test_expect_success ' squash' '
150151 git reset --hard twerp &&
151152 echo B > file7 &&
153+ test_tick &&
152154 GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
153155 echo "******************************" &&
154156 FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 &&
You can’t perform that action at this time.
0 commit comments