* [DOC] merge-file: document that merge.conflictStyle requires a repository
@ 2026-02-05 15:06 Yannik Tausch
2026-02-05 19:11 ` Junio C Hamano
0 siblings, 1 reply; 12+ messages in thread
From: Yannik Tausch @ 2026-02-05 15:06 UTC (permalink / raw)
To: git; +Cc: Manuel Lerchner, Yannik Tausch, gitster
Hi,
We noticed that `git merge-file` only respects the `merge.conflictStyle`
configuration when run inside a repository. Outside a repository, the
setting is ignored and only the `--diff3`/`--zdiff3` flags work.
Looking at the history, this appears to be intentional since b541248467
("merge.conflictstyle: choose between merge and diff3 -m styles", 2008),
which explicitly gates config reading on being inside a repository.
This behavior surprised me, and I couldn't find it documented anywhere.
Would a small documentation patch to git-merge-file.txt be welcome,
noting that the config is only read when inside a repository?
Something like adding to the --diff3 option description:
When run inside a repository, the `merge.conflictStyle`
configuration variable can be used as a default for this option.
Thanks,
Yannik Tausch
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [DOC] merge-file: document that merge.conflictStyle requires a repository 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 0 siblings, 1 reply; 12+ messages in thread From: Junio C Hamano @ 2026-02-05 19:11 UTC (permalink / raw) To: Yannik Tausch; +Cc: git, Manuel Lerchner, Yannik Tausch Yannik Tausch <dev@ytausch.de> writes: > We noticed that `git merge-file` only respects the `merge.conflictStyle` > configuration when run inside a repository. Outside a repository, the > setting is ignored and only the `--diff3`/`--zdiff3` flags work. > > Looking at the history, this appears to be intentional since b541248467 > ("merge.conflictstyle: choose between merge and diff3 -m styles", 2008), > which explicitly gates config reading on being inside a repository. > > This behavior surprised me, and I couldn't find it documented anywhere. > Would a small documentation patch to git-merge-file.txt be welcome, > noting that the config is only read when inside a repository? Or even better, teach the command to read (limited set of) configuration files. By definition, you cannot read from per-repository configuration file when working outside a repository, but these days we let our commands read configuration from system and personal configuration files, I think. Back in 2008, it is understandable we couldn't. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] merge-file: honor merge.conflictStyle outside of a repository 2026-02-05 19:11 ` Junio C Hamano @ 2026-02-05 20:27 ` Yannik Tausch 2026-02-05 20:44 ` Junio C Hamano 2026-02-05 20:51 ` Kristoffer Haugsbakk 0 siblings, 2 replies; 12+ messages in thread From: Yannik Tausch @ 2026-02-05 20:27 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Manuel Lerchner, Yannik Tausch > Junio C Hamano <gitster@pobox.com> writes: > > Yannik Tausch <dev@ytausch.de> writes: > >> We noticed that `git merge-file` only respects the `merge.conflictStyle` >> configuration when run inside a repository. Outside a repository, the >> setting is ignored and only the `--diff3`/`--zdiff3` flags work. >> >> Looking at the history, this appears to be intentional since b541248467 >> ("merge.conflictstyle: choose between merge and diff3 -m styles", 2008), >> which explicitly gates config reading on being inside a repository. >> >> This behavior surprised me, and I couldn't find it documented anywhere. >> Would a small documentation patch to git-merge-file.txt be welcome, >> noting that the config is only read when inside a repository? > > Or even better, teach the command to read (limited set of) > configuration files. > > By definition, you cannot read from per-repository configuration > file when working outside a repository, but these days we let our > commands read configuration from system and personal configuration > files, I think. Back in 2008, it is understandable we couldn't. Thanks for the suggestion. Here's a patch: 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 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. 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. +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 && + 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 && + test_cmp nongit-expect nongit-actual +' + test_expect_success 'marker size' ' cat >expect <<-\EOF && Dominus regit me, -- 2.52.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] merge-file: honor merge.conflictStyle outside of a repository 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 1 sibling, 0 replies; 12+ messages in thread From: Junio C Hamano @ 2026-02-05 20:44 UTC (permalink / raw) To: Yannik Tausch; +Cc: git, Manuel Lerchner, Yannik Tausch Yannik Tausch <dev@ytausch.de> writes: > - 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; Wouldn't it suffice to unconditionally execute the body of the if (startup_info->have_repository) block to pass "repo" we obtained from the caller to repo_config() instead of the_repository? The caller of this function passes us either the_repository or NULL and repo_config() does the very-early thing when passed NULL as the repo, signalling that we are outside a repository. IOW, something like diff --git c/builtin/merge-file.c w/builtin/merge-file.c index 46775d0c79..f9de636884 100644 --- c/builtin/merge-file.c +++ w/builtin/merge-file.c @@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt, int cmd_merge_file(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { const char *names[3] = { 0 }; mmfile_t mmfs[3] = { 0 }; @@ -95,12 +95,10 @@ int cmd_merge_file(int argc, xmp.style = 0; xmp.favor = 0; - if (startup_info->have_repository) { - /* Read the configuration file */ - repo_config(the_repository, git_xmerge_config, NULL); - if (0 <= git_xmerge_style) - xmp.style = git_xmerge_style; - } + /* Read the configuration file */ + repo_config(repo, 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) ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] merge-file: honor merge.conflictStyle outside of a repository 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 2026-02-05 21:55 ` [PATCH v2] " Yannik Tausch 1 sibling, 1 reply; 12+ messages in thread From: Kristoffer Haugsbakk @ 2026-02-05 20:51 UTC (permalink / raw) To: Yannik Tausch, Junio C Hamano; +Cc: git, Manuel Lerchner, Yannik Tausch 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 2026-02-05 20:51 ` Kristoffer Haugsbakk @ 2026-02-05 21:55 ` Yannik Tausch 2026-02-06 21:53 ` Junio C Hamano 0 siblings, 1 reply; 12+ messages in thread From: Yannik Tausch @ 2026-02-05 21:55 UTC (permalink / raw) To: Kristoffer Haugsbakk, gitster; +Cc: git, Manuel Lerchner, Yannik Tausch > Junio C Hamano <gitster@pobox.com> wrote: > Wouldn't it suffice to unconditionally execute the body of the if > (startup_info->have_repository) block to pass "repo" we obtained > from the caller to repo_config() instead of the_repository? The > caller of this function passes us either the_repository or NULL and > repo_config() does the very-early thing when passed NULL as the > repo, signalling that we are outside a repository. Jup, looks like I missed that. Implemented your suggestion! > Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote: > Preferably the message should discuss the code as it exists without the > patch applied in the present tense. (SubmittingPatches present-tense) Fixed! > >> 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. Added! > You need to replace this blank line with a `+` if you want this to be > the second paragraph on this option. Fixed! > 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. I also don’t understand why, but considering your point, I don’t see a reason to not use the regular expect/actual convention. Fixed. > It seems you might as well break the lines for this command further with > some `\` to get closer to the soft limit. Done! Here is the new patch: From 9fa437c70bfd328cfdfe9cfca982b49b70ad033f Mon Sep 17 00:00:00 2001 From: Yannik Tausch <dev@ytausch.de> Date: Thu, 5 Feb 2026 21:09:52 +0100 Subject: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository When running outside a repository, git merge-file ignores the merge.conflictStyle configuration variable entirely. Since the function receives `repo` from the caller (which is NULL outside a repository), and repo_config() falls back to reading system and user configuration when passed NULL, pass `repo` to repo_config() unconditionally. Also document that merge.conflictStyle is honored. Signed-off-by: Yannik Tausch <dev@ytausch.de> --- Notes: Changes since v1: - Use repo parameter directly with repo_config() (Junio) - Fix AsciiDoc continuation, rename test files, break long lines (Kristoffer) Documentation/git-merge-file.adoc | 3 +++ builtin/merge-file.c | 12 +++++------ t/t6403-merge-file.sh | 36 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Documentation/git-merge-file.adoc b/Documentation/git-merge-file.adoc index 71915a00fa..9dc5d8a370 100644 --- a/Documentation/git-merge-file.adoc +++ b/Documentation/git-merge-file.adoc @@ -85,6 +85,9 @@ object store and the object ID of its blob is written to standard output. --zdiff3:: Show conflicts in "zdiff3" style. ++ +The `--diff3` and `--zdiff3` options default to the value of the +`merge.conflictStyle` configuration variable (see linkgit:git-config[1]). --ours:: --theirs:: diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 46775d0c79..f9de636884 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt, int cmd_merge_file(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { const char *names[3] = { 0 }; mmfile_t mmfs[3] = { 0 }; @@ -95,12 +95,10 @@ int cmd_merge_file(int argc, xmp.style = 0; xmp.favor = 0; - if (startup_info->have_repository) { - /* Read the configuration file */ - repo_config(the_repository, git_xmerge_config, NULL); - if (0 <= git_xmerge_style) - xmp.style = git_xmerge_style; - } + /* Read the configuration file */ + repo_config(repo, 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..4d6e748320 100755 --- a/t/t6403-merge-file.sh +++ b/t/t6403-merge-file.sh @@ -428,6 +428,42 @@ 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 >expect <<-\EOF && + 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" >actual && + test_cmp expect actual +' + test_expect_success 'marker size' ' cat >expect <<-\EOF && Dominus regit me, -- 2.52.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 2026-02-05 21:55 ` [PATCH v2] " Yannik Tausch @ 2026-02-06 21:53 ` Junio C Hamano 2026-02-07 21:28 ` Yannik Tausch 0 siblings, 1 reply; 12+ messages in thread From: Junio C Hamano @ 2026-02-06 21:53 UTC (permalink / raw) To: Yannik Tausch; +Cc: Kristoffer Haugsbakk, git, Manuel Lerchner, Yannik Tausch Yannik Tausch <dev@ytausch.de> writes: >> Junio C Hamano <gitster@pobox.com> wrote: > >> Wouldn't it suffice to unconditionally execute the body of the if >> (startup_info->have_repository) block to pass "repo" we obtained >> from the caller to repo_config() instead of the_repository? The >> caller of this function passes us either the_repository or NULL and >> repo_config() does the very-early thing when passed NULL as the >> repo, signalling that we are outside a repository. > > Jup, looks like I missed that. Implemented your suggestion! > ... > Done! > > Here is the new patch: > > From 9fa437c70bfd328cfdfe9cfca982b49b70ad033f Mon Sep 17 00:00:00 2001 > From: Yannik Tausch <dev@ytausch.de> > Date: Thu, 5 Feb 2026 21:09:52 +0100 > Subject: [PATCH v2] merge-file: honor merge.conflictStyle outside of a > repository Please do not send patches this way. Giving responses to review comments is very good and strongly encouraged, but stop the response message with "a new version of the patch coming!" and have a separate message for the patch itself. It sometimes is done to interject a sample patch in the middle of a discussion, but then the convention is ... continuation of an existing discussion ... So, how about doing things this way? --- >8 --- Subject: the title of the patch The proposed log message for the commit comes here Signed-off-by: you --- ... notes, diffstat, diff ... i.e., use a scissors line to tell the receiving end that the rest of the message is a patch message, and override the Subject: with an in-body header. Omit the (From <object-name> Mon Sep 17 2001) "magic" line, "From:" and "Date:". The last two can be taken from the e-mail message anyway. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 2026-02-06 21:53 ` Junio C Hamano @ 2026-02-07 21:28 ` Yannik Tausch 2026-02-07 21:37 ` Yannik Tausch 0 siblings, 1 reply; 12+ messages in thread From: Yannik Tausch @ 2026-02-07 21:28 UTC (permalink / raw) To: Junio C Hamano; +Cc: Kristoffer Haugsbakk, git, Manuel Lerchner, Yannik Tausch > Junio C Hamano <gitster@pobox.com> wrote: > > Please do not send patches this way. Giving responses to review > comments is very good and strongly encouraged, but stop the response > message with "a new version of the patch coming!" and have a separate > message for the patch itself. > > It sometimes is done to interject a sample patch in the middle of a > discussion, but then the convention is > > ... continuation of an existing discussion ... > > So, how about doing things this way? > > --- >8 --- > Subject: the title of the patch > > The proposed log message for the commit comes here > > Signed-off-by: you > --- > > ... notes, diffstat, diff ... > > i.e., use a scissors line to tell the receiving end that the rest of > the message is a patch message, and override the Subject: with an > in-body header. Omit the (From <object-name> Mon Sep 17 2001) > "magic" line, "From:" and "Date:". The last two can be taken from > the e-mail message anyway. Thanks for your feedback on the patch submission format. Resending v2 as a separate message. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 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 0 siblings, 2 replies; 12+ messages in thread From: Yannik Tausch @ 2026-02-07 21:37 UTC (permalink / raw) To: Junio C Hamano; +Cc: Kristoffer Haugsbakk, git, Manuel Lerchner, Yannik Tausch When running outside a repository, git merge-file ignores the merge.conflictStyle configuration variable entirely. Since the function receives `repo` from the caller (which is NULL outside a repository), and repo_config() falls back to reading system and user configuration when passed NULL, pass `repo` to repo_config() unconditionally. Also document that merge.conflictStyle is honored. Signed-off-by: Yannik Tausch <dev@ytausch.de> --- Notes: Changes since v1: - Use repo parameter directly with repo_config() (Junio) - Fix AsciiDoc continuation, rename test files, break long lines (Kristoffer) Documentation/git-merge-file.adoc | 3 +++ builtin/merge-file.c | 12 +++++------ t/t6403-merge-file.sh | 36 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Documentation/git-merge-file.adoc b/Documentation/git-merge-file.adoc index 71915a00fa..9dc5d8a370 100644 --- a/Documentation/git-merge-file.adoc +++ b/Documentation/git-merge-file.adoc @@ -85,6 +85,9 @@ object store and the object ID of its blob is written to standard output. --zdiff3:: Show conflicts in "zdiff3" style. ++ +The `--diff3` and `--zdiff3` options default to the value of the +`merge.conflictStyle` configuration variable (see linkgit:git-config[1]). --ours:: --theirs:: diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 46775d0c79..f9de636884 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt, int cmd_merge_file(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { const char *names[3] = { 0 }; mmfile_t mmfs[3] = { 0 }; @@ -95,12 +95,10 @@ int cmd_merge_file(int argc, xmp.style = 0; xmp.favor = 0; - if (startup_info->have_repository) { - /* Read the configuration file */ - repo_config(the_repository, git_xmerge_config, NULL); - if (0 <= git_xmerge_style) - xmp.style = git_xmerge_style; - } + /* Read the configuration file */ + repo_config(repo, 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..4d6e748320 100755 --- a/t/t6403-merge-file.sh +++ b/t/t6403-merge-file.sh @@ -428,6 +428,42 @@ 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 >expect <<-\EOF && + 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" >actual && + test_cmp expect actual +' + test_expect_success 'marker size' ' cat >expect <<-\EOF && Dominus regit me, -- 2.52.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 2026-02-07 21:37 ` Yannik Tausch @ 2026-02-07 21:47 ` Kristoffer Haugsbakk 2026-02-09 9:08 ` Patrick Steinhardt 1 sibling, 0 replies; 12+ messages in thread From: Kristoffer Haugsbakk @ 2026-02-07 21:47 UTC (permalink / raw) To: Yannik Tausch, Junio C Hamano; +Cc: git, Manuel Lerchner, Yannik Tausch On Sat, Feb 7, 2026, at 22:37, Yannik Tausch wrote: > When running outside a repository, git merge-file ignores the > merge.conflictStyle configuration variable entirely. Since the > function receives `repo` from the caller (which is NULL outside a > repository), and repo_config() falls back to reading system and user > configuration when passed NULL, pass `repo` to repo_config() > unconditionally. > > Also document that merge.conflictStyle is honored. > > Signed-off-by: Yannik Tausch <dev@ytausch.de> > --- This looks good to me. Based on my previous feedback. > > Notes: > Changes since v1: > - Use repo parameter directly with repo_config() (Junio) > - Fix AsciiDoc continuation, rename test files, break long > lines (Kristoffer) Nice and tidy change notes/changelog. >[snip] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 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 1 sibling, 1 reply; 12+ messages in thread From: Patrick Steinhardt @ 2026-02-09 9:08 UTC (permalink / raw) To: Yannik Tausch Cc: Junio C Hamano, Kristoffer Haugsbakk, git, Manuel Lerchner, Yannik Tausch On Sat, Feb 07, 2026 at 10:37:48PM +0100, Yannik Tausch wrote: > diff --git a/builtin/merge-file.c b/builtin/merge-file.c > index 46775d0c79..f9de636884 100644 > --- a/builtin/merge-file.c > +++ b/builtin/merge-file.c > @@ -95,12 +95,10 @@ int cmd_merge_file(int argc, > xmp.style = 0; > xmp.favor = 0; > > - if (startup_info->have_repository) { > - /* Read the configuration file */ > - repo_config(the_repository, git_xmerge_config, NULL); > - if (0 <= git_xmerge_style) > - xmp.style = git_xmerge_style; > - } > + /* Read the configuration file */ > + repo_config(repo, 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) Makes sense. I was briefly wondering about error handling in the old/new code, but unknown keys are already handled by `git_xmerge_config()`, and we'd die in case we see one. So this patch looks good to me overall, thanks! Patrick ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] merge-file: honor merge.conflictStyle outside of a repository 2026-02-09 9:08 ` Patrick Steinhardt @ 2026-02-09 16:13 ` Junio C Hamano 0 siblings, 0 replies; 12+ messages in thread From: Junio C Hamano @ 2026-02-09 16:13 UTC (permalink / raw) To: Patrick Steinhardt Cc: Yannik Tausch, Kristoffer Haugsbakk, git, Manuel Lerchner, Yannik Tausch Patrick Steinhardt <ps@pks.im> writes: > On Sat, Feb 07, 2026 at 10:37:48PM +0100, Yannik Tausch wrote: >> diff --git a/builtin/merge-file.c b/builtin/merge-file.c >> index 46775d0c79..f9de636884 100644 >> --- a/builtin/merge-file.c >> +++ b/builtin/merge-file.c >> @@ -95,12 +95,10 @@ int cmd_merge_file(int argc, >> xmp.style = 0; >> xmp.favor = 0; >> >> - if (startup_info->have_repository) { >> - /* Read the configuration file */ >> - repo_config(the_repository, git_xmerge_config, NULL); >> - if (0 <= git_xmerge_style) >> - xmp.style = git_xmerge_style; >> - } >> + /* Read the configuration file */ >> + repo_config(repo, 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) > > Makes sense. I was briefly wondering about error handling in the old/new > code, but unknown keys are already handled by `git_xmerge_config()`, and > we'd die in case we see one. > > So this patch looks good to me overall, thanks! > > Patrick Yeah, looking good. Thanks, both of you. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-02-09 16:13 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox