summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-20 22:42:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-01-20 22:42:04 (GMT)
commitcea20f24738c558d56483402db1ddfebd0362ee4 (patch)
tree2d5010857dd1d87b4b5735dea3d423acb68836fb /git-rebase--interactive.sh
parentcc6b41cc7d38c1b2de9809c0995087a2378d27ec (diff)
parentf59baa502f49c3f1579a82bc37d2bb3ce9e7b5da (diff)
downloadgit-cea20f24738c558d56483402db1ddfebd0362ee4.zip
git-cea20f24738c558d56483402db1ddfebd0362ee4.tar.gz
git-cea20f24738c558d56483402db1ddfebd0362ee4.tar.bz2
Merge branch 'ns/rebase-auto-squash'
* ns/rebase-auto-squash: rebase -i --autosquash: auto-squash commits Conflicts: git-rebase--interactive.sh
Diffstat (limited to 'git-rebase--interactive.sh')
-rwxr-xr-xgit-rebase--interactive.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d0b59c9..2e56e64 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -28,6 +28,7 @@ abort abort rebasing process and restore original branch
skip skip current patch and continue rebasing process
no-verify override pre-rebase hook from stopping the operation
root rebase all reachable commmits up to the root(s)
+autosquash move commits that begin with squash!/fixup! under -i
"
. git-sh-setup
@@ -46,6 +47,7 @@ ONTO=
VERBOSE=
OK_TO_SKIP_PRE_REBASE=
REBASE_ROOT=
+AUTOSQUASH=
GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
mark the corrected paths with 'git add <paths>', and
@@ -519,6 +521,37 @@ get_saved_options () {
test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
}
+# Rearrange the todo list that has both "pick sha1 msg" and
+# "pick sha1 fixup!/squash! msg" appears in it so that the latter
+# comes immediately after the former, and change "pick" to
+# "fixup"/"squash".
+rearrange_squash () {
+ sed -n -e 's/^pick \([0-9a-f]*\) \(squash\)! /\1 \2 /p' \
+ -e 's/^pick \([0-9a-f]*\) \(fixup\)! /\1 \2 /p' \
+ "$1" >"$1.sq"
+ test -s "$1.sq" || return
+
+ used=
+ while read pick sha1 message
+ do
+ case " $used" in
+ *" $sha1 "*) continue ;;
+ esac
+ echo "$pick $sha1 $message"
+ while read squash action msg
+ do
+ case "$message" in
+ "$msg"*)
+ echo "$action $squash $action! $msg"
+ used="$used$squash "
+ ;;
+ esac
+ done <"$1.sq"
+ done >"$1.rearranged" <"$1"
+ cat "$1.rearranged" >"$1"
+ rm -f "$1.sq" "$1.rearranged"
+}
+
LF='
'
parse_onto () {
@@ -643,6 +676,9 @@ first and then run 'git rebase --continue' again."
--root)
REBASE_ROOT=t
;;
+ --autosquash)
+ AUTOSQUASH=t
+ ;;
--onto)
shift
ONTO=$(parse_onto "$1") ||
@@ -802,6 +838,7 @@ first and then run 'git rebase --continue' again."
fi
test -s "$TODO" || echo noop >> "$TODO"
+ test -n "$AUTOSQUASH" && rearrange_squash "$TODO"
cat >> "$TODO" << EOF
# Rebase $SHORTREVISIONS onto $SHORTONTO