File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ die_with_patch () {
60
60
die " $2 "
61
61
}
62
62
63
+ die_abort () {
64
+ rm -rf " $DOTEST "
65
+ die " $1 "
66
+ }
67
+
63
68
pick_one () {
64
69
case " $1 " in -n) sha1=$2 ;; * ) sha1=$1 ;; esac
65
70
git rev-parse --verify $sha1 || die " Invalid commit name: $sha1 "
212
217
-C* )
213
218
die " Interactive rebase uses merge, so $1 does not make sense"
214
219
;;
215
- -v)
220
+ -v|--verbose )
216
221
VERBOSE=t
217
222
;;
218
223
-i|--interactive)
264
269
echo $ONTO > " $DOTEST " /onto
265
270
test t = " $VERBOSE " && : > " $DOTEST " /verbose
266
271
272
+ SHORTUPSTREAM=$( git rev-parse --short $UPSTREAM )
273
+ SHORTHEAD=$( git rev-parse --short $HEAD )
274
+ SHORTONTO=$( git rev-parse --short $ONTO )
267
275
cat > " $TODO " << EOF
268
- # Rebasing $UPSTREAM ..$HEAD onto $ONTO
276
+ # Rebasing $SHORTUPSTREAM ..$SHORTHEAD onto $SHORTONTO
269
277
#
270
278
# Commands:
271
279
# pick = use commit
@@ -277,13 +285,16 @@ EOF
277
285
sed " s/^/pick /" >> " $TODO "
278
286
279
287
test -z " $( grep -ve ' ^$' -e ' ^#' < $TODO ) " &&
280
- die " Nothing to do"
288
+ die_abort " Nothing to do"
281
289
282
290
cp " $TODO " " $TODO " .backup
283
291
${VISUAL:- ${EDITOR:- vi} } " $TODO " ||
284
292
die " Could not execute editor"
285
293
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
287
298
esac
288
299
shift
289
300
done
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ test_expect_success 'abort' '
140
140
test_expect_success ' retain authorship' '
141
141
echo A > file7 &&
142
142
git add file7 &&
143
+ test_tick &&
143
144
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
144
145
git tag twerp &&
145
146
git rebase -i --onto master HEAD^ &&
@@ -149,6 +150,7 @@ test_expect_success 'retain authorship' '
149
150
test_expect_success ' squash' '
150
151
git reset --hard twerp &&
151
152
echo B > file7 &&
153
+ test_tick &&
152
154
GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
153
155
echo "******************************" &&
154
156
FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 &&
You can’t perform that action at this time.
0 commit comments