From: "David D. Kilzer" <ddkilzer@xxxxxxxxxx> When performing an interactive rebase that preserves merges with rerere enabled, the --rerere-autoupdate switch should be passed to git-merge. Signed-off-by: David D. Kilzer <ddkilzer@xxxxxxxxxx> --- git-rebase--interactive.sh | 7 ++- t/t3420-rebase-preserve-merges-with-rerere.sh | 75 +++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100755 t/t3420-rebase-preserve-merges-with-rerere.sh diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 2e13258..958bbf8 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -297,9 +297,12 @@ pick_one_preserving_merges () { msg_content="$(commit_message $sha1)" # No point in merging the first parent, that's HEAD new_parents=${new_parents# $first_parent} + # If rerere is enabled, pass the --rerere-autoupdate flag + test "$(git config --bool rerere.enabled)" = "true" && + rerere_autoupdate=--rerere-autoupdate || rerere_autoupdate= if ! do_with_author output \ - git merge --no-ff ${strategy:+-s $strategy} -m \ - "$msg_content" $new_parents + git merge --no-ff ${strategy:+-s $strategy} $rerere_autoupdate \ + -m "$msg_content" $new_parents then printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG die_with_patch $sha1 "Error redoing merge $sha1" diff --git a/t/t3420-rebase-preserve-merges-with-rerere.sh b/t/t3420-rebase-preserve-merges-with-rerere.sh new file mode 100755 index 0000000..679937d --- /dev/null +++ b/t/t3420-rebase-preserve-merges-with-rerere.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E. Schindelin +# Copyright (c) 2012 David D. Kilzer +# + +test_description='git rebase -i -p should use rerere to resolve conflicts if enabled' +. ./test-lib.sh + +. "$TEST_DIRECTORY"/lib-rebase.sh + +set_fake_editor + +# Setup +# +# A--AA--B <-- master +# \ +# \ +# \ +# C <-- topic1 + +test_expect_success 'setup' ' + test_commit A file1 && + test_commit AA file2 && + test_commit B file1 && + git checkout -b topic1 HEAD^ && + test_commit C file1 && + git checkout master +' + +# Use rerere to resolve conflicts +# +# Before interactive rebase: +# +# A--AA--B <-- master +# \ \ +# \ M <-- merge1-baseline, merge1 +# \ / +# C <-- topic1 +# +# After interactive rebase: +# +# A--AA--B <-- master +# |\ \ +# | \ M <-- merge1-baseline +# | \ / +# | C <-- topic1 +# \ \ +# \ M' <-- merge1 +# \ / +# B' + +test_expect_success 'rebase -i -p uses rerere to resolve conflicts' ' + git config rerere.enabled true && + git rerere clear && + + git checkout -b merge1 master && + test_must_fail git merge topic1 && + test "`git rerere status`" = "file1" && + printf "B\nC\n" > file1 && + git add file1 && + git commit -m "M: Merge with conflict resolved." && + git branch merge1-baseline && + + FAKE_LINES="edit 1 2 3" git rebase -i -p HEAD~2 && + echo BB >> file2 && + git add file2 && + git commit -m "B'\'': Edit file2 to prevent fast-forward." --amend && + test_must_fail git rebase --continue && + git commit -m "M'\'': Merge with conflict resolved by rerere." && + git rebase --continue && + git diff --exit-code merge1-baseline..merge1 file1 +' + +test_done -- 1.7.9.6 (Apple Git-31) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html