Re: [PATCH 2/2] add -i: default to the built-in implementation
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-12-01 13:43:36
On Tue, Nov 30 2021, Johannes Schindelin via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
From: Johannes Schindelin <redacted> In 9a5315edfdf (Merge branch 'js/patch-mode-in-others-in-c', 2020-02-05), Git acquired a built-in implementation of `git add`'s interactive mode that could be turned on via the config option `add.interactive.useBuiltin`. The first official Git version to support this knob was v2.26.0. In 2df2d81ddd0 (add -i: use the built-in version when feature.experimental is set, 2020-09-08), this built-in implementation was also enabled via `feature.experimental`. The first version with this change was v2.29.0. More than a year (and very few bug reports) later, it is time to declare the built-in implementation mature and to turn it on by default. We specifically leave the `add.interactive.useBuiltin` configuration in place, to give users an "escape hatch" in the unexpected case should they encounter a previously undetected bug in that implementation. Signed-off-by: Johannes Schindelin <redacted> --- Documentation/config/add.txt | 6 +++--- builtin/add.c | 15 +++++---------- ci/run-build-and-tests.sh | 2 +- t/README | 2 +- t/t2016-checkout-patch.sh | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-)diff --git a/Documentation/config/add.txt b/Documentation/config/add.txt index c9f748f81cb..3e859f34197 100644 --- a/Documentation/config/add.txt +++ b/Documentation/config/add.txt@@ -7,6 +7,6 @@ add.ignore-errors (deprecated):: variables. add.interactive.useBuiltin:: - [EXPERIMENTAL] Set to `true` to use the experimental built-in - implementation of the interactive version of linkgit:git-add[1] - instead of the Perl script version. Is `false` by default. + Set to `false` to fall back to the original Perl implementation of + the interactive version of linkgit:git-add[1] instead of the built-in + version. Is `true` by default.
I think this would be a bit better if we just stole the version you added for stash.useBuiltin entirely. I.e. from your 336ad8424cb (stash: document stash.useBuiltin, 2019-05-14), with the relevant s/shell script/Perl/g etc. replaced. I.e. that version encouraged users to report any bugs, because we were really going to remove it soon, as we then did for rebase.useBuiltin in 9bcde4d5314 (rebase: remove transitory rebase.useBuiltin setting & env, 2021-03-23). The wording in the opening paragraph is also a bit more to the point there, i.e. calling it "legacy" rather than "original [...] implementation". (I notice that the stash.useBuiltin is still there in-tree, hrm...)
quoted hunk ↗ jump to hunk
diff --git a/builtin/add.c b/builtin/add.c index ef6b619c45e..8ef230a345b 100644 --- a/builtin/add.c +++ b/builtin/add.c@@ -237,17 +237,12 @@ int run_add_interactive(const char *revision, const char *patch_mode, int use_builtin_add_i = git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1); - if (use_builtin_add_i < 0) { - int experimental; - if (!git_config_get_bool("add.interactive.usebuiltin", - &use_builtin_add_i)) - ; /* ok */ - else if (!git_config_get_bool("feature.experimental", &experimental) && - experimental) - use_builtin_add_i = 1; - } + if (use_builtin_add_i < 0 && + git_config_get_bool("add.interactive.usebuiltin", + &use_builtin_add_i)) + use_builtin_add_i = 1; - if (use_builtin_add_i == 1) { + if (use_builtin_add_i != 0) {
Style/idiom: This should just be "if (use_builtin_add_i)". I.e. before we cared about not catching -1 here, but now that it's true by default we don't care about the distinction between -1 or 1 anymore, we just want it not to be 0 here.