From 79f43447d2b542d1e521987287822ff376d43e93 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Wed, 20 Apr 2016 18:20:56 +0000 Subject: git-rebase--merge: don't include absent parent as a base Absent this fix, attempts to rebase an orphan branch using "rebase -m" fails with: $ git rebase -m ORPHAN_TARGET_BASE First, rewinding head to replay your work on top of it... fatal: Could not parse object 'ORPHAN_ROOT_SHA^' Unknown exit code (128) from command: git-merge-recursive ORPHAN_ROOT_SHA^ -- HEAD ORPHAN_ROOT_SHA To fix, this will only include the rebase root's parent as a base if it exists, so that in cases of rebasing an orphan branch, it is a simple two-way merge. Note the default rebase behavior does not fail: $ git rebase ORPHAN_TARGET_BASE First, rewinding head to replay your work on top of it... Applying: ORPHAN_ROOT_COMMIT_MSG Using index info to reconstruct a base tree... A few tests were expecting the old behaviour to forbid rebasing such a history with "rebase -m", which now need to expect them to succeed. Signed-off-by: Ben Woosley Signed-off-by: Junio C Hamano --- git-rebase--merge.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-rebase--merge.sh') diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh index 2cc2a6d27..8d43db906 100644 --- a/git-rebase--merge.sh +++ b/git-rebase--merge.sh @@ -67,7 +67,9 @@ call_merge () { GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY fi test -z "$strategy" && strategy=recursive - eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"' + # If cmt doesn't have a parent, don't include it as a base + base=$(git rev-parse --verify --quiet $cmt^) + eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"' rv=$? case "$rv" in 0) -- cgit v1.2.1