From b499549401cb2b1f6c30d09681380fd519938eb0 Mon Sep 17 00:00:00 2001 From: Marc Branchaud Date: Wed, 24 Mar 2010 16:34:04 -0400 Subject: Teach rebase the --no-ff option. For git-rebase.sh, --no-ff is a synonym for --force-rebase. For git-rebase--interactive.sh, --no-ff cherry-picks all the commits in the rebased branch, instead of fast-forwarding over any unchanged commits. --no-ff offers an alternative way to deal with reverted merges. Instead of "reverting the revert" you can use "rebase --no-ff" to recreate the branch with entirely new commits (they're new because at the very least the committer time is different). This obviates the need to revert the reversion, as you can re-merge the new topic branch directly. Added an addendum to revert-a-faulty-merge.txt describing the situation and how to use --no-ff to handle it. Signed-off-by: Marc Branchaud Signed-off-by: Junio C Hamano --- git-rebase--interactive.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'git-rebase--interactive.sh') diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 3e4fd1456..d5468b047 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -20,6 +20,7 @@ v,verbose display a diffstat of what changed upstream onto= rebase onto given branch instead of upstream p,preserve-merges try to recreate merges instead of ignoring them s,strategy= use the given merge strategy +no-ff cherry-pick all commits, even if unchanged m,merge always used (no-op) i,interactive always used (no-op) Actions: @@ -103,6 +104,7 @@ VERBOSE= OK_TO_SKIP_PRE_REBASE= REBASE_ROOT= AUTOSQUASH= +NEVER_FF= GIT_CHERRY_PICK_HELP=" After resolving the conflicts, mark the corrected paths with 'git add ', and @@ -222,7 +224,7 @@ do_with_author () { } pick_one () { - no_ff= + no_ff=$NEVER_FF case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1" test -d "$REWRITTEN" && @@ -742,6 +744,9 @@ first and then run 'git rebase --continue' again." -i) # yeah, we know ;; + --no-ff) + NEVER_FF=t + ;; --root) REBASE_ROOT=t ;; @@ -927,7 +932,7 @@ EOF has_action "$TODO" || die_abort "Nothing to do" - test -d "$REWRITTEN" || skip_unnecessary_picks + test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks git update-ref ORIG_HEAD $HEAD output git checkout $ONTO && do_rest -- cgit v1.2.1