git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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"
Previous: Fabian RuchNext: Fabian Ruch
Message 3 of 8 in “Apparent bug in git rebase with a merge commit”
  1. David M. LloydOct 7, 2014
  2. rebase -m: Use empty tree base for parentless commitsFabian Ruch, Oct 9, 2014
  3. Junio C HamanoOct 9, 2014
  4. Fabian RuchOct 9, 2014
  5. Junio C HamanoOct 9, 2014
  6. Fabian RuchOct 13, 2014
  7. Derek MooreOct 9, 2014
  8. David M. LloydOct 9, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.