git rebase: Support non-interactive merge-preserving rebase
PATCH 2/3 git rebase: Support non-interactive merge-preserving rebase
Previously, 'git rebase --preserve-merges' would only work in interactive mode. For some workflows, this was quite a limitation.
This patch adds a workaround, invoking the git-rebase--interactive helper with GIT_EDITOR set to :
in case the user passes "-p" but not "-i" to the rebase command.
The effect is that the interactive rebase helper is used, but the user won't see an editor.
Since this patch fixes the latter of the two expected testfailures in t3409-rebase-preserve-merges, that test is now set to expect success.
---
Documentation/git-rebase.txt | 3 +-- git-rebase.sh | 22 +++++++++++++++++++--- t/t3409-rebase-preserve-merges.sh | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-)
Documentation/git-rebase.txt +1 -4
@@ -250,8 +250,7 @@ OPTIONS -p:: --preserve-merges:: - Instead of ignoring merges, try to recreate them. This option - only works in interactive mode. + Instead of ignoring merges, try to recreate them.
include::merge-strategies.txt[]
git-rebase.sh +0 -0
@@ -138,10 +138,26 @@ finish_rb_merge () {
}
is_interactive () {
- test -f "$dotest"/interactive ||
- while :; do case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
+ while test $# != 0
+ do
+ case "$1" in
+ -i|--interactive)
+ interactive_rebase=explicit
+ break
+ ;;
+ -p|--preserve-merges)
+ interactive_rebase=implied
+ ;;
+ esac
shift
- done && test -n "$1"
+ done
+
+ if [ "$interactive_rebase" = implied ]; then
+ GIT_EDITOR=:
+ export GIT_EDITOR
+ fi
+
+ test -n "$interactive_rebase" || test -f "$dotest"/interactive
}
test -f "$GIT_DIR"/rebase-apply/applying &&
t/t3409-rebase-preserve-merges.sh +0 -0
@@ -57,7 +57,7 @@ test_expect_failure 'git pull --rebase -p on moved topic' '
test $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) = 1
'
-test_expect_failure 'rebase -p merge on moved topic' ' +test_expect_success 'rebase -p merge on moved topic' '
cd ../clone2 && git fetch && git rebase -p origin/topic &&
Signature · 1 line
1.6.0.2.307.gc4275.dirty