@matheusbsbs / matheus-bagliano / commits / c54b7817f4
Fork 0

rebase -i: several cleanups

Support "--verbose" in addition to "-v", show short names in the list comment, clean up if there is nothing to do, and add several "test_ticks" in the test script. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

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