All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>, git@vger.kernel.org
Cc: "David Aguilar" <davvid@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Sergey Organov" <sorganov@gmail.com>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>,
	"Elijah Newren" <newren@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Denton Liu" <liu.denton@gmail.com>
Subject: Re: [PATCH 4/7] checkout: fix merge.conflictstyle handling
Date: Thu, 10 Jun 2021 10:32:24 +0100	[thread overview]
Message-ID: <b4b9264d-1c17-1a62-f0ec-2791ab20adeb@gmail.com> (raw)
In-Reply-To: <20210609192842.696646-5-felipe.contreras@gmail.com>

On 09/06/2021 20:28, Felipe Contreras wrote:
> Currently both merge.conflictStyle and `git commit --merge
> --conflict=diff3` don't work together, since the former wrongly
> overrides the later.
> 
> The way merge configurations are handled is not correct.
> It should be possible to do git_config(merge_recursive_config, ...) just
> like we can with git_diff_basic_config and others.

It would be helpful to explain what the problem with 
merge_recursive_config() actually is rather than just saying "it should 
be possible ..."

> Therefore builtins like `git merge` can't call this function at the
> right time.
 >
> We shuffle the functions a little bit so at least merge_recursive_config
> doesn't call git_xmerge_config directly and thus override previous
> configurations.

Rather than papering of the problem, how difficult would it be to add a 
field to ll_merge_options and pass the conflict style with that rather 
than fiddling with the order that we set a global variable.

Does this change affect 'am/apply -3'? - Do they still read the config 
setting properly?

Best Wishes

Phillip

> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>   builtin/merge-recursive.c          |  3 +++
>   builtin/merge.c                    |  4 ++++
>   merge-recursive.c                  |  2 +-
>   sequencer.c                        |  5 +++++
>   t/t6440-config-conflict-markers.sh | 31 ++++++++++++++++++++++++++++++
>   5 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
> index a4bfd8fc51..80f9279b4c 100644
> --- a/builtin/merge-recursive.c
> +++ b/builtin/merge-recursive.c
> @@ -4,6 +4,7 @@
>   #include "tag.h"
>   #include "merge-recursive.h"
>   #include "xdiff-interface.h"
> +#include "config.h"
>   
>   static const char builtin_merge_recursive_usage[] =
>   	"git %s <base>... -- <head> <remote> ...";
> @@ -30,6 +31,8 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
>   	char *better1, *better2;
>   	struct commit *result;
>   
> +	git_config(git_xmerge_config, NULL);
> +
>   	init_merge_options(&o, the_repository);
>   	if (argv[0] && ends_with(argv[0], "-subtree"))
>   		o.subtree_shift = "";
> diff --git a/builtin/merge.c b/builtin/merge.c
> index eddb8ae70d..7aa3dbb111 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -43,6 +43,7 @@
>   #include "commit-reach.h"
>   #include "wt-status.h"
>   #include "commit-graph.h"
> +#include "xdiff-interface.h"
>   
>   #define DEFAULT_TWOHEAD (1<<0)
>   #define DEFAULT_OCTOPUS (1<<1)
> @@ -659,6 +660,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
>   	if (status)
>   		return status;
>   	status = git_gpg_config(k, v, NULL);
> +	if (status)
> +		return status;
> +	status = git_xmerge_config(k, v, NULL);
>   	if (status)
>   		return status;
>   	return git_diff_ui_config(k, v, cb);
> diff --git a/merge-recursive.c b/merge-recursive.c
> index d146bb116f..10e6e1e4d1 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -3845,7 +3845,7 @@ static void merge_recursive_config(struct merge_options *opt)
>   		} /* avoid erroring on values from future versions of git */
>   		free(value);
>   	}
> -	git_config(git_xmerge_config, NULL);
> +	git_config(git_default_config, NULL);
>   }
>   
>   void init_merge_options(struct merge_options *opt,
> diff --git a/sequencer.c b/sequencer.c
> index 0bec01cf38..9e2bdca0f6 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -34,6 +34,7 @@
>   #include "commit-reach.h"
>   #include "rebase-interactive.h"
>   #include "reset.h"
> +#include "xdiff-interface.h"
>   
>   #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
>   
> @@ -224,6 +225,10 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
>   	if (status)
>   		return status;
>   
> +	status = git_xmerge_config(k, v, NULL);
> +	if (status)
> +		return status;
> +
>   	return git_diff_basic_config(k, v, NULL);
>   }
>   
> diff --git a/t/t6440-config-conflict-markers.sh b/t/t6440-config-conflict-markers.sh
> index 44f79ac91b..485ad0eee0 100755
> --- a/t/t6440-config-conflict-markers.sh
> +++ b/t/t6440-config-conflict-markers.sh
> @@ -89,4 +89,35 @@ test_expect_success 'notes' '
>   	)
>   '
>   
> +test_expect_success 'checkout' '
> +	test_create_repo checkout &&
> +	(
> +		test_commit checkout &&
> +
> +		fill a b c d e >content &&
> +		git add content &&
> +		git commit -m initial &&
> +
> +		git checkout -b simple master &&
> +		fill a c e >content &&
> +		git commit -a -m simple &&
> +
> +		fill b d >content &&
> +		git checkout --merge master &&
> +		! grep -E "\|+" content &&
> +
> +		git config merge.conflictstyle merge &&
> +
> +		git checkout -f simple &&
> +		fill b d >content &&
> +		git checkout --merge --conflict=diff3 master &&
> +		grep -E "\|+" content &&
> +
> +		git checkout -f simple &&
> +		fill b d >content &&
> +		git checkout --merge --conflict=merge master &&
> +		! grep -E "\|+" content
> +	)
> +'
> +
>   test_done
> 

  reply	other threads:[~2021-06-10  9:32 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 19:28 [PATCH 0/7] Make diff3 the default conflict style Felipe Contreras
2021-06-09 19:28 ` [PATCH 1/7] test: add merge style config test Felipe Contreras
2021-06-09 19:42   ` Eric Sunshine
2021-06-09 20:29     ` Felipe Contreras
2021-06-10  9:18   ` Phillip Wood
2021-06-10 13:26     ` Felipe Contreras
2021-06-10 14:54       ` Phillip Wood
2021-06-10 16:34         ` Felipe Contreras
2021-06-10 14:58       ` Phillip Wood
2021-06-10 16:47         ` Felipe Contreras
2021-06-11  9:19           ` Phillip Wood
2021-06-11 14:39             ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 2/7] merge-tree: fix merge.conflictstyle handling Felipe Contreras
2021-06-09 19:28 ` [PATCH 3/7] notes: " Felipe Contreras
2021-06-09 19:28 ` [PATCH 4/7] checkout: " Felipe Contreras
2021-06-10  9:32   ` Phillip Wood [this message]
2021-06-10 14:11     ` Felipe Contreras
2021-06-10 14:50       ` Phillip Wood
2021-06-10 16:32         ` Felipe Contreras
2021-06-11  9:18           ` Phillip Wood
2021-06-11 14:34             ` Felipe Contreras
2021-06-11  9:18   ` Phillip Wood
2021-06-09 19:28 ` [PATCH 5/7] xdiff: rename XDL_MERGE_STYLE_DIFF3 Felipe Contreras
2021-06-10  9:21   ` Phillip Wood
2021-06-10 13:33     ` Felipe Contreras
2021-06-11  3:17     ` Junio C Hamano
2021-06-11 13:42       ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 6/7] xdiff: simplify style assignments Felipe Contreras
2021-06-10  9:26   ` Phillip Wood
2021-06-10 13:50     ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 7/7] xdiff: make diff3 the default conflictStyle Felipe Contreras
2021-06-10  6:41   ` Johannes Sixt
2021-06-10  7:53     ` Đoàn Trần Công Danh
2021-06-10 13:18       ` Felipe Contreras
2021-06-10 13:18     ` Felipe Contreras
2021-06-10 13:49     ` Jeff King
2021-06-10 16:00       ` Felipe Contreras
2021-06-10 16:31         ` Jeff King
2021-06-11  1:20       ` Junio C Hamano
2021-06-11  6:23         ` Johannes Sixt
2021-06-11  6:43           ` Junio C Hamano
2021-06-11  7:02             ` Johannes Sixt
2021-06-11  7:14               ` Junio C Hamano
2021-06-11 11:51                 ` Sergey Organov
2021-06-11 15:32                   ` Felipe Contreras
2021-06-11 15:52                     ` Sergey Organov
2021-06-11 16:36                       ` Felipe Contreras
     [not found]                     ` <CABPp-BHRQSF2_aYTBfpfnW4Bh3Hz7vLFj_QNGj8R4WeCS6_utw@mail.gmail.com>
2021-06-11 17:57                       ` Felipe Contreras
2021-06-11 19:02                         ` Elijah Newren
2021-06-11 21:05                           ` Felipe Contreras
2021-06-11 21:40                             ` Elijah Newren
2021-06-13 14:34                               ` Felipe Contreras
2021-06-11 16:41                   ` Johannes Sixt
2021-06-11 17:21                     ` Felipe Contreras
2021-06-11 17:40                       ` Sergey Organov
2021-06-11 18:10                         ` Felipe Contreras
2021-06-11 18:22                           ` Sergey Organov
2021-06-11 14:28                 ` Felipe Contreras
2021-06-11 14:25               ` Felipe Contreras
2021-06-11 16:53                 ` Johannes Sixt
     [not found]                 ` <CABPp-BH0aRiSUw03nSK6jHRNQ+zcpUzr6WjeJ5GpdUCqCKxbag@mail.gmail.com>
2021-06-11 17:32                   ` Felipe Contreras
2021-06-11 17:57                     ` Elijah Newren
2021-06-11 18:28                       ` Felipe Contreras
2021-06-11 14:20           ` Felipe Contreras
2021-06-11 14:09         ` Felipe Contreras
2021-06-10  9:40   ` Phillip Wood
2021-06-10 14:19     ` Felipe Contreras
2021-06-17 17:40 ` [PATCH 0/7] Make diff3 the default conflict style Phillip Wood
2021-06-17 18:24   ` Felipe Contreras

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=b4b9264d-1c17-1a62-f0ec-2791ab20adeb@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=avarab@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=davvid@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=sorganov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.