public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail•com>
To: "Yannik Tausch" <dev@ytausch•de>, "Junio C Hamano" <gitster@pobox•com>
Cc: git@vger•kernel.org,
	"Manuel Lerchner" <manuel.lerchner@quantco•com>,
	"Yannik Tausch" <yannik.tausch@quantco•com>
Subject: Re: [PATCH] merge-file: honor merge.conflictStyle outside of a repository
Date: Thu, 05 Feb 2026 21:51:51 +0100	[thread overview]
Message-ID: <fa7fc215-03eb-492d-9af4-457482c56a48@app.fastmail.com> (raw)
In-Reply-To: <3724733C-FECB-47F5-841C-84DE9792332D@ytausch.de>

On Thu, Feb 5, 2026, at 21:27, Yannik Tausch wrote:
>[snip]
> From bed0035d38072c67e0be8eedb0cf98da936cbac6 Mon Sep 17 00:00:00 2001
> From: Yannik Tausch <dev@ytausch•de>
> Date: Thu, 5 Feb 2026 21:09:52 +0100
> Subject: [PATCH] merge-file: honor merge.conflictStyle outside of a repository
>
> When running outside a repository, git merge-file previously ignored
> the merge.conflictStyle configuration variable entirely. Teach it to

Preferably the message should discuss the code as it exists without the
patch applied in the present tense. (SubmittingPatches present-tense)

> read from system and user configuration files using
> read_very_early_config(), so that users can set their preferred
> conflict style globally and have it honored even outside a repository.

The update to the documentation might merit an “also”? I dunno.

>
> Signed-off-by: Yannik Tausch <dev@ytausch•de>
> ---
>  Documentation/git-merge-file.adoc |  3 +++
>  builtin/merge-file.c              | 11 +++++-----
>  t/t6403-merge-file.sh             | 34 +++++++++++++++++++++++++++++++
>  3 files changed, 43 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/git-merge-file.adoc
> b/Documentation/git-merge-file.adoc
> index 71915a00fa..773037aa14 100644
> --- a/Documentation/git-merge-file.adoc
> +++ b/Documentation/git-merge-file.adoc
> @@ -86,6 +86,9 @@ object store and the object ID of its blob is written
> to standard output.
>  --zdiff3::
>  	Show conflicts in "zdiff3" style.
>

You need to replace this blank line with a `+` if you want this to be
the second paragraph on this option.

> +The `--diff3` and `--zdiff3` options default to the value of the
> +`merge.conflictStyle` configuration variable (see linkgit:git-config[1]).
> +
>  --ours::
>  --theirs::
>  --union::
> diff --git a/builtin/merge-file.c b/builtin/merge-file.c
> index 46775d0c79..1b6e16b9cb 100644
> --- a/builtin/merge-file.c
> +++ b/builtin/merge-file.c
> @@ -95,12 +95,13 @@ int cmd_merge_file(int argc,
>  	xmp.style = 0;
>  	xmp.favor = 0;
>
> -	if (startup_info->have_repository) {
> -		/* Read the configuration file */
> +	if (startup_info->have_repository)
>  		repo_config(the_repository, git_xmerge_config, NULL);
> -		if (0 <= git_xmerge_style)
> -			xmp.style = git_xmerge_style;
> -	}
> +	else
> +		read_very_early_config(git_xmerge_config, NULL);
> +
> +	if (0 <= git_xmerge_style)
> +		xmp.style = git_xmerge_style;
>
>  	argc = parse_options(argc, argv, prefix, options, merge_file_usage, 0);
>  	if (argc != 3)
> diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh
> index 06ab4d7aed..9df9f878c8 100755
> --- a/t/t6403-merge-file.sh
> +++ b/t/t6403-merge-file.sh
> @@ -428,6 +428,40 @@ test_expect_success '"diff3 -m" style output (2)' '
>  	test_cmp expect actual
>  '
>
> +test_expect_success 'merge.conflictStyle honored outside repo' '
> +	test_config_global merge.conflictStyle diff3 &&
> +	cat >nongit-base <<-\EOF &&
> +	line1
> +	original
> +	line3
> +	EOF
> +	cat >nongit-ours <<-\EOF &&
> +	line1
> +	ours
> +	line3
> +	EOF
> +	cat >nongit-theirs <<-\EOF &&
> +	line1
> +	theirs
> +	line3
> +	EOF
> +	cat >nongit-expect <<-\EOF &&

Some tests in this file already use the regular expect/actual but there
are also many one-off names like expect.c/myers_output.c. I don’t
understand why. But I’m just thinking out loud here.

> +	line1
> +	<<<<<<< ours
> +	ours
> +	||||||| base
> +	original
> +	=======
> +	theirs
> +	>>>>>>> theirs
> +	line3
> +	EOF
> +	test_must_fail nongit git merge-file -p \
> +		-L ours -L base -L theirs \
> +		"$PWD/nongit-ours" "$PWD/nongit-base" "$PWD/nongit-theirs" >nongit-actual &&

It seems you might as well break the lines for this command further with
some `\` to get closer to the soft limit.

> +	test_cmp nongit-expect nongit-actual
> +'
> +
>  test_expect_success 'marker size' '
>  	cat >expect <<-\EOF &&
>  	Dominus regit me,
> --
> 2.52.0

  parent reply	other threads:[~2026-02-05 20:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 15:06 [DOC] merge-file: document that merge.conflictStyle requires a repository Yannik Tausch
2026-02-05 19:11 ` Junio C Hamano
2026-02-05 20:27   ` [PATCH] merge-file: honor merge.conflictStyle outside of " Yannik Tausch
2026-02-05 20:44     ` Junio C Hamano
2026-02-05 20:51     ` Kristoffer Haugsbakk [this message]
2026-02-05 21:55       ` [PATCH v2] " Yannik Tausch
2026-02-06 21:53         ` Junio C Hamano
2026-02-07 21:28           ` Yannik Tausch
2026-02-07 21:37             ` Yannik Tausch
2026-02-07 21:47               ` Kristoffer Haugsbakk
2026-02-09  9:08               ` Patrick Steinhardt
2026-02-09 16:13                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa7fc215-03eb-492d-9af4-457482c56a48@app.fastmail.com \
    --to=kristofferhaugsbakk@fastmail$(echo .)com \
    --cc=dev@ytausch$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=manuel.lerchner@quantco$(echo .)com \
    --cc=yannik.tausch@quantco$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox