From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, peff@peff.net, jnareb@gmail.com,
pclouds@gmail.com, carenas@gmail.com, avarab@gmail.com,
Junio C Hamano <gitster@pobox.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 5/5] repo-settings: create feature.experimental setting
Date: Tue, 23 Jul 2019 17:20:17 +0200 (CEST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1907231708280.21907@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <da7685936f44a32121ec0568df2a9f23e4003506.1563818059.git.gitgitgadget@gmail.com>
Hi Stolee,
On Mon, 22 Jul 2019, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <dstolee@microsoft.com>
>
> The 'feature.experimental' setting includes config options that are
> not committed to become defaults, but could use additional testing.
>
> Update the following config settings to take new defaults, and to
> use the repo_settings struct if not already using them:
>
> * 'pack.useSparse=true'
>
> * 'merge.directoryRenames=true'
>
> * 'fetch.negotiationAlgorithm=skipping'
>
> In the case of fetch.negotiationAlgorithm, the existing logic
> would load the config option only when about to use the setting,
> so had a die() statement on an unknown string value. This is
> removed as now the config is parsed under prepare_repo_settings().
> In general, this die() is probably misplaced and not valuable.
> A test was removed that checked this die() statement executed.
Good.
> [...]
> diff --git a/merge-recursive.c b/merge-recursive.c
> index 12300131fc..162d5a4753 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -28,6 +28,7 @@
> #include "submodule.h"
> #include "revision.h"
> #include "commit-reach.h"
> +#include "repo-settings.h"
>
> struct path_hashmap_entry {
> struct hashmap_entry e;
> @@ -1375,10 +1376,14 @@ static int handle_rename_via_dir(struct merge_options *opt,
> * there is no content merge to do; just move the file into the
> * desired final location.
> */
> + struct repository *r = the_repository;
> const struct rename *ren = ci->ren1;
> const struct diff_filespec *dest = ren->pair->two;
> char *file_path = dest->path;
> - int mark_conflicted = (opt->detect_directory_renames == 1);
I actually don't think that we want to do that; the `opt` parameter is
passed to the merge recursive algorithm specifically so that it can be
overridden by the caller.
Instead, what we should do, I think, is to change `init_merge_options()`
(which already gets a parameter of type `struct repository *`) so that
it does not hard-code the `detect_directory_renames` value to `1` but to
query the repo settings instead.
> + int mark_conflicted;
> +
> + prepare_repo_settings(r);
> + mark_conflicted = (r->settings->merge_directory_renames == MERGE_DIRECTORY_RENAMES_CONFLICT);
> assert(ren->dir_rename_original_dest);
>
> if (!opt->call_depth && would_lose_untracked(opt, dest->path)) {
> @@ -2850,6 +2855,7 @@ static int detect_and_process_renames(struct merge_options *opt,
> struct string_list *entries,
> struct rename_info *ri)
> {
> + struct repository *r = the_repository;
> struct diff_queue_struct *head_pairs, *merge_pairs;
> struct hashmap *dir_re_head, *dir_re_merge;
> int clean = 1;
> @@ -2863,7 +2869,8 @@ static int detect_and_process_renames(struct merge_options *opt,
> head_pairs = get_diffpairs(opt, common, head);
> merge_pairs = get_diffpairs(opt, common, merge);
>
> - if (opt->detect_directory_renames) {
> + prepare_repo_settings(r);
> + if (r->settings->merge_directory_renames) {
> dir_re_head = get_directory_renames(head_pairs);
> dir_re_merge = get_directory_renames(merge_pairs);
>
> @@ -3112,6 +3119,7 @@ static int handle_rename_normal(struct merge_options *opt,
> const struct diff_filespec *b,
> struct rename_conflict_info *ci)
> {
> + struct repository *r = the_repository;
> struct rename *ren = ci->ren1;
> struct merge_file_info mfi;
> int clean;
> @@ -3121,7 +3129,9 @@ static int handle_rename_normal(struct merge_options *opt,
> clean = handle_content_merge(&mfi, opt, path, was_dirty(opt, path),
> o, a, b, ci);
>
> - if (clean && opt->detect_directory_renames == 1 &&
> + prepare_repo_settings(r);
> + if (clean &&
> + r->settings->merge_directory_renames == MERGE_DIRECTORY_RENAMES_CONFLICT &&
> ren->dir_rename_original_dest) {
> if (update_stages(opt, path,
> NULL,
> @@ -3155,6 +3165,7 @@ static void dir_rename_warning(const char *msg,
> static int warn_about_dir_renamed_entries(struct merge_options *opt,
> struct rename *ren)
> {
> + struct repository *r = the_repository;
> const char *msg;
> int clean = 1, is_add;
>
> @@ -3166,12 +3177,13 @@ static int warn_about_dir_renamed_entries(struct merge_options *opt,
> return clean;
>
> /* Sanity checks */
> - assert(opt->detect_directory_renames > 0);
> + prepare_repo_settings(r);
> + assert(r->settings->merge_directory_renames > 0);
> assert(ren->dir_rename_original_type == 'A' ||
> ren->dir_rename_original_type == 'R');
>
> /* Check whether to treat directory renames as a conflict */
> - clean = (opt->detect_directory_renames == 2);
> + clean = (r->settings->merge_directory_renames == MERGE_DIRECTORY_RENAMES_TRUE);
>
> is_add = (ren->dir_rename_original_type == 'A');
> if (ren->dir_rename_original_type == 'A' && clean) {
> @@ -3662,15 +3674,6 @@ static void merge_recursive_config(struct merge_options *opt)
> opt->merge_detect_rename = git_config_rename("merge.renames", value);
> free(value);
> }
> - if (!git_config_get_string("merge.directoryrenames", &value)) {
> - int boolval = git_parse_maybe_bool(value);
> - if (0 <= boolval) {
> - opt->detect_directory_renames = boolval ? 2 : 0;
> - } else if (!strcasecmp(value, "conflict")) {
> - opt->detect_directory_renames = 1;
> - } /* avoid erroring on values from future versions of git */
> - free(value);
> - }
> git_config(git_xmerge_config, NULL);
> }
>
> @@ -3687,7 +3690,6 @@ void init_merge_options(struct merge_options *opt,
> opt->renormalize = 0;
> opt->diff_detect_rename = -1;
> opt->merge_detect_rename = -1;
> - opt->detect_directory_renames = 1;
In other words: here.
> merge_recursive_config(opt);
> merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
> if (merge_verbosity)
> diff --git a/merge-recursive.h b/merge-recursive.h
> index c2b7bb65c6..b8eba244ee 100644
> --- a/merge-recursive.h
> +++ b/merge-recursive.h
> @@ -22,7 +22,6 @@ struct merge_options {
> unsigned renormalize : 1;
> long xdl_opts;
> int verbosity;
> - int detect_directory_renames;
> int diff_detect_rename;
> int merge_detect_rename;
> int diff_rename_limit;
> diff --git a/repo-settings.c b/repo-settings.c
> index 9e4b8e6268..5e9249c437 100644
> --- a/repo-settings.c
> +++ b/repo-settings.c
> @@ -9,6 +9,12 @@ static int git_repo_config(const char *key, const char *value, void *cb)
> {
> struct repo_settings *rs = (struct repo_settings *)cb;
>
> + if (!strcmp(key, "feature.experimental")) {
> + UPDATE_DEFAULT(rs->pack_use_sparse, 1);
> + UPDATE_DEFAULT(rs->merge_directory_renames, MERGE_DIRECTORY_RENAMES_TRUE);
> + UPDATE_DEFAULT(rs->fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
> + return 0;
> + }
> if (!strcmp(key, "feature.manycommits")) {
> UPDATE_DEFAULT(rs->core_commit_graph, 1);
> UPDATE_DEFAULT(rs->gc_write_commit_graph, 1);
> @@ -50,6 +56,23 @@ static int git_repo_config(const char *key, const char *value, void *cb)
> "using 'keep' default value"), value);
> return 0;
> }
> + if (!strcmp(key, "merge.directoryrenames")) {
> + int bool_value = git_parse_maybe_bool(value);
> + if (0 <= bool_value) {
> + rs->merge_directory_renames = bool_value ? MERGE_DIRECTORY_RENAMES_TRUE : 0;
> + } else if (!strcasecmp(value, "conflict")) {
> + rs->merge_directory_renames = MERGE_DIRECTORY_RENAMES_CONFLICT;
> + }
> + return 0;
> + }
> + if (!strcmp(key, "fetch.negotiationalgorithm")) {
> + if (!strcasecmp(value, "skipping")) {
> + rs->fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
> + } else {
> + rs->fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
> + }
> + return 0;
> + }
>
> return 1;
> }
> @@ -64,10 +87,14 @@ void prepare_repo_settings(struct repository *r)
> /* Defaults */
> r->settings->core_commit_graph = -1;
> r->settings->gc_write_commit_graph = -1;
> - r->settings->pack_use_sparse = -1;
> +
> r->settings->index_version = -1;
> r->settings->core_untracked_cache = -1;
>
> + r->settings->pack_use_sparse = -1;
This reordering at this stage in the patch series is a bit confusing.
Maybe add it at the location where you want it to end up to begin with?
Or use `memset(..., -1, ...)`.
> + r->settings->merge_directory_renames = -1;
> + r->settings->fetch_negotiation_algorithm = -1;
> +
> repo_config(r, git_repo_config, r->settings);
>
> /* Hack for test programs like test-dump-untracked-cache */
> @@ -75,4 +102,7 @@ void prepare_repo_settings(struct repository *r)
> r->settings->core_untracked_cache = CORE_UNTRACKED_CACHE_KEEP;
> else
> UPDATE_DEFAULT(r->settings->core_untracked_cache, CORE_UNTRACKED_CACHE_KEEP);
> +
> + UPDATE_DEFAULT(r->settings->merge_directory_renames, MERGE_DIRECTORY_RENAMES_CONFLICT);
> + UPDATE_DEFAULT(r->settings->fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
> }
> diff --git a/repo-settings.h b/repo-settings.h
> index bac9b87d49..cecf7d0028 100644
> --- a/repo-settings.h
> +++ b/repo-settings.h
> @@ -4,12 +4,22 @@
> #define CORE_UNTRACKED_CACHE_WRITE (1 << 0)
> #define CORE_UNTRACKED_CACHE_KEEP (1 << 1)
>
> +#define MERGE_DIRECTORY_RENAMES_CONFLICT 1
> +#define MERGE_DIRECTORY_RENAMES_TRUE 2
> +
> +#define FETCH_NEGOTIATION_DEFAULT 1
> +#define FETCH_NEGOTIATION_SKIPPING 2
> +
Again, I'd prefer enums.
The rest looks pretty fine to me (I have to admit that I only glanced
over the tests, though).
Thanks!
Dscho
> struct repo_settings {
> int core_commit_graph;
> int gc_write_commit_graph;
> - int pack_use_sparse;
> +
> int index_version;
> int core_untracked_cache;
> +
> + int pack_use_sparse;
> + int merge_directory_renames;
> + int fetch_negotiation_algorithm;
> };
>
> struct repository;
> diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh
> index 8a14be51a1..f70cbcc9ca 100755
> --- a/t/t5552-skipping-fetch-negotiator.sh
> +++ b/t/t5552-skipping-fetch-negotiator.sh
> @@ -60,29 +60,6 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
> have_not_sent c6 c4 c3
> '
>
> -test_expect_success 'unknown fetch.negotiationAlgorithm values error out' '
> - rm -rf server client trace &&
> - git init server &&
> - test_commit -C server to_fetch &&
> -
> - git init client &&
> - test_commit -C client on_client &&
> - git -C client checkout on_client &&
> -
> - test_config -C client fetch.negotiationAlgorithm invalid &&
> - test_must_fail git -C client fetch "$(pwd)/server" 2>err &&
> - test_i18ngrep "unknown fetch negotiation algorithm" err &&
> -
> - # Explicit "default" value
> - test_config -C client fetch.negotiationAlgorithm default &&
> - git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" &&
> -
> - # Implementation detail: If there is nothing to fetch, we will not error out
> - test_config -C client fetch.negotiationAlgorithm invalid &&
> - git -C client fetch "$(pwd)/server" 2>err &&
> - test_i18ngrep ! "unknown fetch negotiation algorithm" err
> -'
> -
> test_expect_success 'when two skips collide, favor the larger one' '
> rm -rf server client trace &&
> git init server &&
> --
> gitgitgadget
>
next prev parent reply other threads:[~2019-07-23 15:20 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 17:54 [PATCH 0/5] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-07-22 17:54 ` [PATCH 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-23 13:12 ` Johannes Schindelin
2019-07-22 17:54 ` [PATCH 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-23 14:53 ` Johannes Schindelin
2019-07-24 10:41 ` Derrick Stolee
2019-07-22 17:54 ` [PATCH 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-22 17:54 ` [PATCH 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-23 15:04 ` Johannes Schindelin
2019-07-24 19:27 ` Derrick Stolee
2019-07-22 17:54 ` [PATCH 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-07-23 15:20 ` Johannes Schindelin [this message]
2019-07-25 1:47 ` Derrick Stolee
2019-07-25 2:23 ` [PATCH v2 0/5] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-25 9:30 ` Johannes Schindelin
2019-07-25 2:23 ` [PATCH v2 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-25 9:36 ` Johannes Schindelin
2019-07-25 2:23 ` [PATCH v2 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-07-25 9:40 ` [PATCH v2 0/5] Create 'feature.*' config area and some centralized config parsing Johannes Schindelin
2019-07-30 19:35 ` [PATCH v3 " Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-30 20:47 ` Junio C Hamano
2019-07-30 19:35 ` [PATCH v3 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-30 20:57 ` Junio C Hamano
2019-07-31 13:17 ` Johannes Schindelin
2019-07-31 15:48 ` Junio C Hamano
2019-07-31 15:01 ` Ævar Arnfjörð Bjarmason
2019-08-01 18:27 ` Derrick Stolee
2019-07-30 19:35 ` [PATCH v3 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-08-08 18:34 ` Elijah Newren
2019-08-08 18:48 ` Derrick Stolee
2019-08-08 18:59 ` Junio C Hamano
2019-08-08 19:12 ` Derrick Stolee
2019-08-08 20:31 ` Elijah Newren
2019-08-08 20:49 ` Derrick Stolee
2019-08-08 19:19 ` Elijah Newren
2019-08-08 20:07 ` Junio C Hamano
2019-08-08 20:46 ` Derrick Stolee
2019-08-13 18:37 ` [PATCH v4 0/6] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 1/6] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 3/6] commit-graph: turn on commit-graph by default Derrick Stolee via GitGitGadget
2021-09-20 0:42 ` Junio C Hamano
2021-09-20 1:22 ` Ævar Arnfjörð Bjarmason
2021-09-20 1:25 ` brian m. carlson
2021-09-20 12:53 ` Phillip Wood
2021-09-20 13:30 ` Ævar Arnfjörð Bjarmason
2021-09-20 18:00 ` Phillip Wood
2021-09-20 19:18 ` Jeff King
2019-08-13 18:37 ` [PATCH v4 2/6] t6501: use 'git gc' in quiet mode Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 4/6] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 5/6] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 6/6] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-08-13 21:04 ` [PATCH v4 0/6] Create 'feature.*' config area and some centralized config parsing Junio C Hamano
2019-08-13 21:08 ` Junio C Hamano
2019-08-14 10:32 ` Derrick Stolee
2019-08-14 10:38 ` Derrick Stolee
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=nycvar.QRO.7.76.6.1907231708280.21907@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=carenas@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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).