Re: [PATCH v1] rebase -m: Use empty tree base for parentless commits
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 9, 2014, 19:05 UTC
- Message-ID
- <xmqq1tqh6p3y.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <bf0e177fbaac91f8c55526729e580fade9f0f395.1412879523.git.bafain@gmail.com>
Fabian Ruch <bafain@gmail.com> writes:
Show 16 quoted lines
> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
> index d3fb67d..3f754ae 100644
> --- a/git-rebase--merge.sh
> +++ b/git-rebase--merge.sh
> @@ -67,7 +67,13 @@ 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"'
> + base=$(git rev-list --parents -1 $cmt | cut -d ' ' -s -f 2 -)
> + if test -z "$base"
> + then
> + # the empty tree sha1
> + base=4b825dc642cb6eb9a060e54bf8d69288fbee4904
> + fi
> + eval 'git-merge-$strategy' $strategy_opts '"$base" -- "$hd" "$cmt"'This looks wrong.
The interface to "git-merge-$strategy" is designed in such a way that each strategy should be capable of taking _no_ base at all.
See how unquoted $common is given to git-merge-$strategy in contrib/examples/git-merge.sh, i.e.
eval 'git-merge-$strategy '"$xopt"' $common -- "$head_arg" "$@"'
where common comes from
common=$(git merge-base ...)
which would be empty when you are looking at disjoint histories.
Also rev-list piped to cut is too ugly to live in our codebase X-<.
Wouldn't it be sufficient to do something like this instead?
eval 'git-merge-$strategy' $strategy_opts \
$(git rev-parse --quiet --verify "$cmt^") -- "$hd" "$cmt"