From: Elijah Newren <newren@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 3/4] merge: make merge.renormalize work for all uses of merge machinery
Date: Mon, 3 Aug 2020 08:07:07 -0700 [thread overview]
Message-ID: <CABPp-BFPjcMatwgC+TQXBcB6_HdK5kW3=vzRTQ94kiCEyLj9Mg@mail.gmail.com> (raw)
In-Reply-To: <xmqqd048svhk.fsf@gitster.c.googlers.com>
On Sun, Aug 2, 2020 at 12:23 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > The 'merge' command is not the only one that does merges; other commands
> > like checkout -m or rebase do as well. Unfortunately, the only area of
> > the code that checked for the "merge.renormalize" config setting was in
> > builtin/merge.c, meaning it could only affect merges performed by the
> > "merge" command. Move the handling of this config setting to
> > merge_recursive_config() so that other commands can benefit from it as
> > well. Fixes a few tests in t6038.
>
> Makes sense, but.
>
> > @@ -771,13 +771,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
> > */
> >
> > add_files_to_cache(NULL, NULL, 0);
> > - /*
> > - * NEEDSWORK: carrying over local changes
> > - * when branches have different end-of-line
> > - * normalization (or clean+smudge rules) is
> > - * a pain; plumb in an option to set
> > - * o.renormalize?
> > - */
> > init_merge_options(&o, the_repository);
>
> Now init_merge_options() takes care of setting o.renormalize, which
> does exactly what the comment wanted to see happen.
>
> > diff --git a/builtin/merge.c b/builtin/merge.c
> > index 7da707bf55..52f03ea715 100644
> > --- a/builtin/merge.c
> > +++ b/builtin/merge.c
> > @@ -72,7 +72,7 @@ static const char **xopts;
> > static size_t xopts_nr, xopts_alloc;
> > static const char *branch;
> > static char *branch_mergeoptions;
> > -static int option_renormalize;
> > +static int option_renormalize = -1;
>
> Do we still need this file-scope static variable at all?
>
> > @@ -621,8 +621,6 @@ static int git_merge_config(const char *k, const char *v, void *cb)
> > return git_config_string(&pull_octopus, k, v);
> > else if (!strcmp(k, "commit.cleanup"))
> > return git_config_string(&cleanup_arg, k, v);
> > - else if (!strcmp(k, "merge.renormalize"))
> > - option_renormalize = git_config_bool(k, v);
>
> We no longer set value to option_renormalize in git_merge_config()
> that is used only from cmd_merge().
>
> > @@ -721,7 +719,8 @@ static int try_merge_strategy(const char *stra
> > if (!strcmp(strategy, "subtree"))
> > o.subtree_shift = "";
> >
> > - o.renormalize = option_renormalize;
> > + if (option_renormalize != -1)
> > + o.renormalize = option_renormalize;
>
> And if somebody sets option_renormalize, then (and only then) we
> override o.renormalize. One line before the precontext of this hunk
> is a call to init_merge_options() that would have set o.renormalize
> by reading merge.renormalize configuration. So there must be another
> place where option_renormalize comes from other than that configuration
> variable.
>
> But I do not see the variable mentioned anywhere else in the
> original The assignment to it in git_merge_config() you just got
> rid of was the only one that used to assign to it.
>
> > diff --git a/merge-recursive.c b/merge-recursive.c
> > index 36948eafb7..a1c8b36ddb 100644
> > --- a/merge-recursive.c
> > +++ b/merge-recursive.c
> > @@ -3791,9 +3791,12 @@ int merge_recursive_generic(struct merge_options *opt,
> > static void merge_recursive_config(struct merge_options *opt)
> > {
> > char *value = NULL;
> > + int renormalize = 0;
> > git_config_get_int("merge.verbosity", &opt->verbosity);
> > git_config_get_int("diff.renamelimit", &opt->rename_limit);
> > git_config_get_int("merge.renamelimit", &opt->rename_limit);
> > + git_config_get_bool("merge.renormalize", &renormalize);
> > + opt->renormalize = renormalize;
> > if (!git_config_get_string("diff.renames", &value)) {
> > opt->detect_renames = git_config_rename("diff.renames", value);
> > free(value);
>
> OK.
>
> IOW, wouldn't the attached be a no-op code clean-up on top?
>
> builtin/merge.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 52f03ea715..74829a838e 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -72,7 +72,6 @@ static const char **xopts;
> static size_t xopts_nr, xopts_alloc;
> static const char *branch;
> static char *branch_mergeoptions;
> -static int option_renormalize = -1;
> static int verbosity;
> static int allow_rerere_auto;
> static int abort_current_merge;
> @@ -719,8 +718,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
> if (!strcmp(strategy, "subtree"))
> o.subtree_shift = "";
>
> - if (option_renormalize != -1)
> - o.renormalize = option_renormalize;
> o.show_rename_progress =
> show_progress == -1 ? isatty(2) : show_progress;
>
Indeed; I'll squash that in for my next iteration.
next prev parent reply other threads:[~2020-08-03 15:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-02 6:33 [PATCH 0/4] Attr fixes Elijah Newren via GitGitGadget
2020-08-02 6:33 ` [PATCH 1/4] t6038: make tests fail for the right reason Elijah Newren via GitGitGadget
2020-08-02 18:17 ` Junio C Hamano
2020-08-02 19:10 ` Eric Sunshine
2020-08-03 15:06 ` Elijah Newren
2020-08-02 6:33 ` [PATCH 2/4] t6038: fix test with obviously incorrect expectations Elijah Newren via GitGitGadget
2020-08-02 19:57 ` Junio C Hamano
2020-08-03 15:36 ` Elijah Newren
2020-08-03 15:50 ` Junio C Hamano
2020-08-02 6:33 ` [PATCH 3/4] merge: make merge.renormalize work for all uses of merge machinery Elijah Newren via GitGitGadget
2020-08-02 19:23 ` Junio C Hamano
2020-08-03 15:07 ` Elijah Newren [this message]
2020-08-02 6:33 ` [PATCH 4/4] checkout: support renormalization with checkout -m <paths> Elijah Newren via GitGitGadget
2020-08-03 18:41 ` [PATCH v2 0/4] Attr fixes Elijah Newren via GitGitGadget
2020-08-03 18:41 ` [PATCH v2 1/4] t6038: make tests fail for the right reason Elijah Newren via GitGitGadget
2020-08-03 18:41 ` [PATCH v2 2/4] t6038: remove problematic test Elijah Newren via GitGitGadget
2020-08-03 18:41 ` [PATCH v2 3/4] merge: make merge.renormalize work for all uses of merge machinery Elijah Newren via GitGitGadget
2020-08-03 18:41 ` [PATCH v2 4/4] checkout: support renormalization with checkout -m <paths> Elijah Newren via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABPp-BFPjcMatwgC+TQXBcB6_HdK5kW3=vzRTQ94kiCEyLj9Mg@mail.gmail.com' \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).