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

Re: [PATCH v3] mergetool: add automerge configuration

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 18, 2020, 00:47 UTC
Message-ID
<xmqqk0tgx7ms.fsf@gitster.c.googlers.com>
In-Reply-To
<20201217054524.856258-1-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 7 quoted lines
> It doesn't make sense to display easily-solvable conflicts in the
> different views of all mergetools.
>
> Only the chunks that warrant conflict markers should be displayed.
>
> In order to unobtrusively do this, add a new configuration:
> mergetool.autoMerge.

As pointed out by others, I think it makes more sense to have mergetool.$tool.autoMerge, with optionally mergetool.autoMerge that can be used as a fallback, and enable it by default. If we can make the default of enabling/disabling per tool, that would be ideal (see my other reply on how to do these).

> +		git merge-file --diff3 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"

Adding "--marker-size 7" to the command line would make the sed scripts below more robust.

Show 22 quoted lines
> +		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"
> +		sed -e '/^||||||| /,/^>>>>>>> /d' -e '/^<<<<<<< /d' "$DIFF3" >"$LOCAL"
> +		sed -e '/^<<<<<<< /,/^=======\r\?$/d' -e '/^>>>>>>> /d' "$DIFF3" >"$REMOTE"
> +		rm -- "$DIFF3"
> +	fi
> +
>  	if test -z "$local_mode" || test -z "$remote_mode"
>  	then
>  		echo "Deleted merge conflict for '$MERGED':"
> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
> index 70afdd06fa..b75c91199b 100755
> --- a/t/t7610-mergetool.sh
> +++ b/t/t7610-mergetool.sh
> @@ -828,4 +828,22 @@ test_expect_success 'mergetool -Oorder-file is honored' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'mergetool automerge' '
> +	test_config mergetool.automerge true &&
> +	test_when_finished "git reset --hard" &&
> +	git checkout -b test${test_count}_b master &&
> +	echo -e "base\n\na" >file1 &&

I think test-lint-shell-syntax should have complained about the use of "echo -e" here (that's the reason why I queued the patch in 'seen' initially but it does not appear in what finally got pushed out).

You can either use the plain-vanilla
	cat >file1 <<-\EOF &&
	...
	EOF

because there is nothing gained by saving number of lines with reduced readability, or can use

	test_write_lines >file1 base "" "" a &&
	...
	test_write_lines >file1 base "" "" c &&
	...
	test_write_lines >file1 local "" "" b &&
	...
	test_write_lines >file1 local "" "" c &&
	...

which would both save number of lines while making it a bit clearer which 'line' corresponds to which other 'line' in different preparation of the same "file1".

Will expect a reroll.  Thanks.
Show 14 quoted lines
> +	git commit -a -m "base" &&
> +	echo -e "base\n\nc" >file1 &&
> +	git commit -a -m "remote update" &&
> +	git checkout -b test${test_count}_a HEAD~ &&
> +	echo -e "local\n\nb" >file1 &&
> +	git commit -a -m "local update" &&
> +	test_must_fail git merge test${test_count}_b &&
> +	yes "" | git mergetool file1 &&
> +	echo -e "local\n\nc" >expect &&
> +	test_cmp expect file1 &&
> +	git commit -m "test resolved with mergetool"
> +'
> +
>  test_done
Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 7 in “mergetool: add automerge configuration”
  1. mergetool: add automerge configurationFelipe Contreras, Dec 17, 2020
  2. Johannes SixtDec 17, 2020
  3. Felipe ContrerasDec 17, 2020
  4. Junio C HamanoDec 18, 2020
  5. Felipe ContrerasDec 18, 2020
  6. Junio C HamanoDec 18, 2020
  7. Felipe ContrerasDec 18, 2020

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.