Skip to content

Commit 4fb1a19

Browse files
dschogitster
authored andcommitted
rebase -i -p: leave a --cc patch when a merge could not be redone
The result is easier to review this way, and the merge resolution has to be done inside the work tree, not by adjusting "the patch" anyway.
1 parent f5b49ea commit 4fb1a19

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

git-rebase--interactive.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,18 @@ mark_action_done () {
115115
}
116116

117117
make_patch () {
118-
parent_sha1=$(git rev-parse --verify "$1"^) ||
119-
die "Cannot get patch for $1^"
120-
git diff-tree -p "$parent_sha1".."$1" > "$DOTEST"/patch
118+
sha1_and_parents="$(git rev-list --parents -1 "$1")"
119+
case "$sha1_and_parents" in
120+
?*' '?*' '?*)
121+
git diff --cc $sha1_and_parents
122+
;;
123+
?*' '?*)
124+
git diff-tree -p "$1^!"
125+
;;
126+
*)
127+
echo "Root commit"
128+
;;
129+
esac > "$DOTEST"/patch
121130
test -f "$DOTEST"/message ||
122131
git cat-file commit "$1" | sed "1,/^$/d" > "$DOTEST"/message
123132
test -f "$DOTEST"/author-script ||

t/t3409-rebase-preserve-merges.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ test_expect_success '--continue works after a conflict' '
8383
test 2 = $(git ls-files B | wc -l) &&
8484
echo Resolved again > B &&
8585
test_must_fail git rebase --continue &&
86+
grep "^@@@ " .git/rebase-merge/patch &&
8687
git add B &&
8788
git rebase --continue &&
8889
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&

0 commit comments

Comments
 (0)