advice: suggest using subcommand "git config set"
PATCH 1/1 advice: suggest using subcommand "git config set"
The advice message currently suggests using "git config advice..." to disable advice messages, but since 00bbdde141f we have the "set" subcommand for config. Change the disable advice message to use the subcommand instead. Change all uses of "git config advice" in the tests to use the subcommand.
---
Notes:
For the tests I just indiscriminately ran:
sed -i "s/git config advice\./git config set advice./" t[0-9]*.sh
advice.c | 2 +- t/t0018-advice.sh | 2 +- t/t3200-branch.sh | 2 +- t/t3404-rebase-interactive.sh | 6 +++--- t/t3501-revert-cherry-pick.sh | 2 +- t/t3507-cherry-pick-conflict.sh | 6 +++--- t/t3510-cherry-pick-sequence.sh | 2 +- t/t3511-cherry-pick-x.sh | 2 +- t/t3602-rm-sparse-checkout.sh | 2 +- t/t3700-add.sh | 6 +++--- t/t3705-add-sparse-checkout.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 ++-- t/t7004-tag.sh | 2 +- t/t7201-co.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- t/t7508-status.sh | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-)
advice.c +1 -1
@@ -93,7 +93,7 @@ static struct {static const char turn_off_instructions[] =N_ ("\n" -"Disable this message with \"git config advice.%s false\"" ); +"Disable this message with \"git config set advice.%s false\"" );static void vadvise (const char *advice,int display_instructions,const char *key,va_list params)
t/t0018-advice.sh +1 -1
@@ -10,7 +10,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME test_expect_success 'advice should be printed when config variable is unset' ' cat >expect <<-\EOF && hint: This is a piece of advice - hint: Disable this message with "git config advice.nestedTag false" + hint: Disable this message with "git config set advice.nestedTag false" EOF test-tool advise "This is a piece of advice" 2>actual && test_cmp expect actual
t/t3200-branch.sh +1 -1
@@ -1696,7 +1696,7 @@ test_expect_success 'errors if given a bad branch name' ' cat <<-\EOF >expect && fatal: '\''foo..bar'\'' is not a valid branch name hint: See `man git check-ref-format` - hint: Disable this message with "git config advice.refSyntax false" + hint: Disable this message with "git config set advice.refSyntax false" EOF test_must_fail git branch foo..bar >actual 2>&1 && test_cmp expect actual
t/t3404-rebase-interactive.sh +3 -3
@@ -2258,20 +2258,20 @@ test_expect_success 'non-merge commands reject merge commits' ' error: ${SQ}pick${SQ} does not accept merge commits hint: ${SQ}pick${SQ} does not take a merge commit. If you wanted to hint: replay the merge, use ${SQ}merge -C${SQ} on the commit. - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 1: pick $oid error: ${SQ}reword${SQ} does not accept merge commits hint: ${SQ}reword${SQ} does not take a merge commit. If you wanted to hint: replay the merge and reword the commit message, use hint: ${SQ}merge -c${SQ} on the commit - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 2: reword $oid error: ${SQ}edit${SQ} does not accept merge commits hint: ${SQ}edit${SQ} does not take a merge commit. If you wanted to hint: replay the merge, use ${SQ}merge -C${SQ} on the commit, and then hint: ${SQ}break${SQ} to give the control back to you so that you can hint: do ${SQ}git commit --amend && git rebase --continue${SQ}. - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 3: edit $oid error: cannot squash merge commit into another commit error: invalid line 4: fixup $oid
t/t3501-revert-cherry-pick.sh +1 -1
@@ -177,7 +177,7 @@ test_expect_success 'advice from failed revert' ' hint: You can instead skip this commit with "git revert --skip". hint: To abort and get back to the state before "git revert", hint: run "git revert --abort". - hint: Disable this message with "git config advice.mergeConflict false" + hint: Disable this message with "git config set advice.mergeConflict false" EOF test_commit --append --no-tag "double-add dream" dream dream && test_must_fail git revert HEAD^ 2>actual &&
t/t3507-cherry-pick-conflict.sh +3 -3
@@ -34,7 +34,7 @@ test_expect_success setup ' git commit --allow-empty --allow-empty-message && git tag empty && git checkout main && - git config advice.detachedhead false + git config set advice.detachedhead false '
@@ -60,7 +60,7 @@ test_expect_success 'advice from failed cherry-pick' ' hint: You can instead skip this commit with "git cherry-pick --skip". hint: To abort and get back to the state before "git cherry-pick", hint: run "git cherry-pick --abort". - hint: Disable this message with "git config advice.mergeConflict false" + hint: Disable this message with "git config set advice.mergeConflict false" EOF test_must_fail git cherry-pick picked 2>actual &&
@@ -75,7 +75,7 @@ test_expect_success 'advice from failed cherry-pick --no-commit' " error: could not apply \$picked... picked hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' - hint: Disable this message with \"git config advice.mergeConflict false\" + hint: Disable this message with \"git config set advice.mergeConflict false\" EOF test_must_fail git cherry-pick --no-commit picked 2>actual &&
t/t3510-cherry-pick-sequence.sh +1 -1
@@ -25,7 +25,7 @@ pristine_detach () { } test_expect_success setup ' - git config advice.detachedhead false && + git config set advice.detachedhead false && echo unrelated >unrelated && git add unrelated && test_commit initial foo a &&
t/t3511-cherry-pick-x.sh +1 -1
@@ -51,7 +51,7 @@ trailing empty lines " test_expect_success setup ' - git config advice.detachedhead false && + git config set advice.detachedhead false && echo unrelated >unrelated && git add unrelated && test_commit initial foo a &&
t/t3602-rm-sparse-checkout.sh +1 -1
@@ -20,7 +20,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF echo b | cat sparse_error_header - >sparse_entry_b_error &&
t/t3700-add.sh +3 -3
@@ -31,7 +31,7 @@ test_expect_success 'Test with no pathspecs' ' cat >expect <<-EOF && Nothing specified, nothing added. hint: Maybe you wanted to say ${SQ}git add .${SQ}? - hint: Disable this message with "git config advice.addEmptyPathspec false" + hint: Disable this message with "git config set advice.addEmptyPathspec false" EOF git add 2>actual && test_cmp expect actual
@@ -375,7 +375,7 @@ test_expect_success '"git add" a embedded repository' ' hint: git rm --cached inner1 hint: hint: See "git help submodule" for more information. - hint: Disable this message with "git config advice.addEmbeddedRepo false" + hint: Disable this message with "git config set advice.addEmbeddedRepo false" warning: adding embedded git repository: inner2 EOF test_cmp expect actual
@@ -413,7 +413,7 @@ cat >expect.err <<\EOF The following paths are ignored by one of your .gitignore files: ignored-file hint: Use -f if you really want to add them. -hint: Disable this message with "git config advice.addIgnoredFile false" +hint: Disable this message with "git config set advice.addIgnoredFile false" EOF cat >expect.out <<\EOF add 'track-this'
t/t3705-add-sparse-checkout.sh +1 -1
@@ -54,7 +54,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF echo sparse_entry | cat sparse_error_header - >sparse_entry_error &&
t/t7002-mv-sparse-checkout.sh +2 -2
@@ -32,7 +32,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF cat >dirty_error_header <<-EOF &&
@@ -45,7 +45,7 @@ test_expect_success 'setup' " hint: To correct the sparsity of these paths, do the following: hint: * Use \"git add --sparse <paths>\" to update the index hint: * Use \"git sparse-checkout reapply\" to apply the sparsity rules - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF "
t/t7004-tag.sh +1 -1
@@ -1850,7 +1850,7 @@ test_expect_success 'recursive tagging should give advice' ' hint: already a tag. If you meant to tag the object that it points to, use: hint: hint: git tag -f nested annotated-v4.0^{} - hint: Disable this message with "git config advice.nestedTag false" + hint: Disable this message with "git config set advice.nestedTag false" EOF git tag -m nested nested annotated-v4.0 2>actual && test_cmp expect actual
t/t7201-co.sh +2 -2
@@ -224,7 +224,7 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && + git config set advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -244,7 +244,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' ' test_expect_success 'checkout to detach HEAD' ' - git config advice.detachedHead true && + git config set advice.detachedHead true && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
t/t7400-submodule-basic.sh +1 -1
@@ -212,7 +212,7 @@ test_expect_success 'submodule add to .gitignored path fails' ' The following paths are ignored by one of your .gitignore files: submod hint: Use -f if you really want to add them. - hint: Disable this message with "git config advice.addIgnoredFile false" + hint: Disable this message with "git config set advice.addIgnoredFile false" EOF # Does not use test_commit due to the ignore echo "*" > .gitignore &&
t/t7508-status.sh +1 -1
@@ -1699,7 +1699,7 @@ test_expect_success 'setup slow status advice' ' EOF git add .gitignore && git commit -m "Add .gitignore" && - git config advice.statusuoption true + git config set advice.statusuoption true ) '
Signature · 1 line
2.47.1.398.g18e7475ebe
Quoted 2 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141fwe have the "set"
When referencing an existing commit, I think there is a preference to use the output of:
$ git show -s --format=reference 00bbdde141f 00bbdde141 (builtin/config: introduce "set" subcommand, 2024-05-06)
Quoted 3 lines
subcommand for config. Change the disable advice message to use the subcommand instead. Change all uses of "git config advice" in the tests to use the subcommand.
Both "git config <config> <value>" and "git config set <config> <value>" are functionally the same operation. So the motivation for this seems to be to push/promote usage of the new "set" subcommand. I find the newer interface to be more intuitive and in line with modern command interfaces so updating the advice turn off messages here seems reasonable to me.
There does appear to be other instances where the the advice turn off instructions are open-coded and thus retain the prior format. This does result in some inconsistency, which may not be a big deal, but maybe it would make sense to also adjust those sites as part of this series as also. Otherwise the changes in this patch look correct.
-Justin
Quoted 9 lines · Justin Tobler
Quoted 2 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141fwe have the "set"When referencing an existing commit, I think there is a preference to use the output of:
$ git show -s --format=reference 00bbdde141f 00bbdde141 (builtin/config: introduce "set" subcommand, 2024-05-06)
Ack.
Quoted 11 lines
Quoted 4 lines
subcommand for config. Change the disable advice message to use the subcommand instead. Change all uses of "git config advice" in the tests to use the subcommand.
Both "git config <config> <value>" and "git config set <config> <value>" are functionally the same operation. So the motivation for this seems to be to push/promote usage of the new "set" subcommand. I find the newer interface to be more intuitive and in line with modern command interfaces so updating the advice turn off messages here seems reasonable to me.
Yes, that was the motivation, I'll make that explicit in the commit message.
Quoted 6 lines
There does appear to be other instances where the the advice turn off instructions are open-coded and thus retain the prior format. This does result in some inconsistency, which may not be a big deal, but maybe it would make sense to also adjust those sites as part of this series as also. Otherwise the changes in this patch look correct.
Fair point. Grepping the .c files yielded three more instances, I'll change those as well.
Thanks,
Bence
Quoted 10 lines · Bence Ferdinandy
Quoted 6 lines · Justin Tobler
On 24/12/04 02:08PM, Bence Ferdinandy wrote:
There does appear to be other instances where the the advice turn off instructions are open-coded and thus retain the prior format. This does result in some inconsistency, which may not be a big deal, but maybe it would make sense to also adjust those sites as part of this series as also. Otherwise the changes in this patch look correct.Fair point. Grepping the .c files yielded three more instances, I'll change those as well.
Yeah. Overall I think it is fine to do an iterative transition to the new interface. git config set is not going to be the only instance that needs changes, but I very much assume that we will have suggestions and warnings all over the place that may recommend other modes of the command like the equivalent of git config get. But these don't have to all happen in the same commit, or even the same patch series, from my point of view.
Thanks for working on this!
Patrick
PATCH v2 1/1 advice: suggest using subcommand "git config set"
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141 (builtin/config: introduce "set" subcommand, 2024-05-06)
we have the "set" subcommand for config. Since using the subcommand is more in-line with the modern interface, any advice should be promoting its usage. Change the disable advice message to use the subcommand instead. Change all uses of "git config advice" in the tests to use the subcommand.
---
Notes:
For the tests I just indiscriminately ran:
sed -i "s/git config advice\./git config set advice./" t[0-9]*.sh
v2: - fixed 3 hardcoded "git config advice" type messages
- made the motiviation more explicit
advice.c | 2 +- commit.c | 2 +- hook.c | 2 +- object-name.c | 2 +- t/t0018-advice.sh | 2 +- t/t3200-branch.sh | 2 +- t/t3404-rebase-interactive.sh | 6 +++--- t/t3501-revert-cherry-pick.sh | 2 +- t/t3507-cherry-pick-conflict.sh | 6 +++--- t/t3510-cherry-pick-sequence.sh | 2 +- t/t3511-cherry-pick-x.sh | 2 +- t/t3602-rm-sparse-checkout.sh | 2 +- t/t3700-add.sh | 6 +++--- t/t3705-add-sparse-checkout.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 ++-- t/t7004-tag.sh | 2 +- t/t7201-co.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- t/t7508-status.sh | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)
advice.c +1 -1
@@ -93,7 +93,7 @@ static struct {static const char turn_off_instructions[] =N_ ("\n" -"Disable this message with \"git config advice.%s false\"" ); +"Disable this message with \"git config set advice.%s false\"" );static void vadvise (const char *advice,int display_instructions,const char *key,va_list params)
commit.c +1 -1
@@ -276,7 +276,7 @@ static int read_graft_file(struct repository *r, const char *graft_file)"to convert the grafts into replace refs.\n" "\n" "Turn this message off by running\n" - "\"git config advice.graftFileDeprecated false\"")); + "\"git config set advice.graftFileDeprecated false\""));while (!strbuf_getwholeline (&buf, fp,'\n' )) {/* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft =read_graft_line (&buf);
hook.c +1 -1
@@ -39,7 +39,7 @@ const char *find_hook(struct repository *r, const char *name)advise (_ ("The '%s' hook was ignored because " "it's not set as executable.\n" "You can disable this warning with " -"`git config advice.ignoredHook false`." ), +"`git config set advice.ignoredHook false`." ), path.buf); } }
object-name.c +1 -1
@@ -952,7 +952,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,"\n" "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" "examine these refs and maybe delete them. Turn this message off by\n" - "running \"git config advice.objectNameWarning false\""); + "running \"git config set advice.objectNameWarning false\"");struct object_id tmp_oid;char *real_ref =NULL ;int refs_found =0 ;
t/t0018-advice.sh +1 -1
@@ -10,7 +10,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME test_expect_success 'advice should be printed when config variable is unset' ' cat >expect <<-\EOF && hint: This is a piece of advice - hint: Disable this message with "git config advice.nestedTag false" + hint: Disable this message with "git config set advice.nestedTag false" EOF test-tool advise "This is a piece of advice" 2>actual && test_cmp expect actual
t/t3200-branch.sh +1 -1
@@ -1696,7 +1696,7 @@ test_expect_success 'errors if given a bad branch name' ' cat <<-\EOF >expect && fatal: '\''foo..bar'\'' is not a valid branch name hint: See `man git check-ref-format` - hint: Disable this message with "git config advice.refSyntax false" + hint: Disable this message with "git config set advice.refSyntax false" EOF test_must_fail git branch foo..bar >actual 2>&1 && test_cmp expect actual
t/t3404-rebase-interactive.sh +3 -3
@@ -2258,20 +2258,20 @@ test_expect_success 'non-merge commands reject merge commits' ' error: ${SQ}pick${SQ} does not accept merge commits hint: ${SQ}pick${SQ} does not take a merge commit. If you wanted to hint: replay the merge, use ${SQ}merge -C${SQ} on the commit. - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 1: pick $oid error: ${SQ}reword${SQ} does not accept merge commits hint: ${SQ}reword${SQ} does not take a merge commit. If you wanted to hint: replay the merge and reword the commit message, use hint: ${SQ}merge -c${SQ} on the commit - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 2: reword $oid error: ${SQ}edit${SQ} does not accept merge commits hint: ${SQ}edit${SQ} does not take a merge commit. If you wanted to hint: replay the merge, use ${SQ}merge -C${SQ} on the commit, and then hint: ${SQ}break${SQ} to give the control back to you so that you can hint: do ${SQ}git commit --amend && git rebase --continue${SQ}. - hint: Disable this message with "git config advice.rebaseTodoError false" + hint: Disable this message with "git config set advice.rebaseTodoError false" error: invalid line 3: edit $oid error: cannot squash merge commit into another commit error: invalid line 4: fixup $oid
t/t3501-revert-cherry-pick.sh +1 -1
@@ -177,7 +177,7 @@ test_expect_success 'advice from failed revert' ' hint: You can instead skip this commit with "git revert --skip". hint: To abort and get back to the state before "git revert", hint: run "git revert --abort". - hint: Disable this message with "git config advice.mergeConflict false" + hint: Disable this message with "git config set advice.mergeConflict false" EOF test_commit --append --no-tag "double-add dream" dream dream && test_must_fail git revert HEAD^ 2>actual &&
t/t3507-cherry-pick-conflict.sh +3 -3
@@ -34,7 +34,7 @@ test_expect_success setup ' git commit --allow-empty --allow-empty-message && git tag empty && git checkout main && - git config advice.detachedhead false + git config set advice.detachedhead false '
@@ -60,7 +60,7 @@ test_expect_success 'advice from failed cherry-pick' ' hint: You can instead skip this commit with "git cherry-pick --skip". hint: To abort and get back to the state before "git cherry-pick", hint: run "git cherry-pick --abort". - hint: Disable this message with "git config advice.mergeConflict false" + hint: Disable this message with "git config set advice.mergeConflict false" EOF test_must_fail git cherry-pick picked 2>actual &&
@@ -75,7 +75,7 @@ test_expect_success 'advice from failed cherry-pick --no-commit' " error: could not apply \$picked... picked hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' - hint: Disable this message with \"git config advice.mergeConflict false\" + hint: Disable this message with \"git config set advice.mergeConflict false\" EOF test_must_fail git cherry-pick --no-commit picked 2>actual &&
t/t3510-cherry-pick-sequence.sh +1 -1
@@ -25,7 +25,7 @@ pristine_detach () { } test_expect_success setup ' - git config advice.detachedhead false && + git config set advice.detachedhead false && echo unrelated >unrelated && git add unrelated && test_commit initial foo a &&
t/t3511-cherry-pick-x.sh +1 -1
@@ -51,7 +51,7 @@ trailing empty lines " test_expect_success setup ' - git config advice.detachedhead false && + git config set advice.detachedhead false && echo unrelated >unrelated && git add unrelated && test_commit initial foo a &&
t/t3602-rm-sparse-checkout.sh +1 -1
@@ -20,7 +20,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF echo b | cat sparse_error_header - >sparse_entry_b_error &&
t/t3700-add.sh +3 -3
@@ -31,7 +31,7 @@ test_expect_success 'Test with no pathspecs' ' cat >expect <<-EOF && Nothing specified, nothing added. hint: Maybe you wanted to say ${SQ}git add .${SQ}? - hint: Disable this message with "git config advice.addEmptyPathspec false" + hint: Disable this message with "git config set advice.addEmptyPathspec false" EOF git add 2>actual && test_cmp expect actual
@@ -375,7 +375,7 @@ test_expect_success '"git add" a embedded repository' ' hint: git rm --cached inner1 hint: hint: See "git help submodule" for more information. - hint: Disable this message with "git config advice.addEmbeddedRepo false" + hint: Disable this message with "git config set advice.addEmbeddedRepo false" warning: adding embedded git repository: inner2 EOF test_cmp expect actual
@@ -413,7 +413,7 @@ cat >expect.err <<\EOF The following paths are ignored by one of your .gitignore files: ignored-file hint: Use -f if you really want to add them. -hint: Disable this message with "git config advice.addIgnoredFile false" +hint: Disable this message with "git config set advice.addIgnoredFile false" EOF cat >expect.out <<\EOF add 'track-this'
t/t3705-add-sparse-checkout.sh +1 -1
@@ -54,7 +54,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF echo sparse_entry | cat sparse_error_header - >sparse_entry_error &&
t/t7002-mv-sparse-checkout.sh +2 -2
@@ -32,7 +32,7 @@ test_expect_success 'setup' " hint: If you intend to update such entries, try one of the following: hint: * Use the --sparse option. hint: * Disable or modify the sparsity rules. - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF cat >dirty_error_header <<-EOF &&
@@ -45,7 +45,7 @@ test_expect_success 'setup' " hint: To correct the sparsity of these paths, do the following: hint: * Use \"git add --sparse <paths>\" to update the index hint: * Use \"git sparse-checkout reapply\" to apply the sparsity rules - hint: Disable this message with \"git config advice.updateSparsePath false\" + hint: Disable this message with \"git config set advice.updateSparsePath false\" EOF "
t/t7004-tag.sh +1 -1
@@ -1850,7 +1850,7 @@ test_expect_success 'recursive tagging should give advice' ' hint: already a tag. If you meant to tag the object that it points to, use: hint: hint: git tag -f nested annotated-v4.0^{} - hint: Disable this message with "git config advice.nestedTag false" + hint: Disable this message with "git config set advice.nestedTag false" EOF git tag -m nested nested annotated-v4.0 2>actual && test_cmp expect actual
t/t7201-co.sh +2 -2
@@ -224,7 +224,7 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && + git config set advice.detachedHead false && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
@@ -244,7 +244,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' ' test_expect_success 'checkout to detach HEAD' ' - git config advice.detachedHead true && + git config set advice.detachedHead true && rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f &&
t/t7400-submodule-basic.sh +1 -1
@@ -212,7 +212,7 @@ test_expect_success 'submodule add to .gitignored path fails' ' The following paths are ignored by one of your .gitignore files: submod hint: Use -f if you really want to add them. - hint: Disable this message with "git config advice.addIgnoredFile false" + hint: Disable this message with "git config set advice.addIgnoredFile false" EOF # Does not use test_commit due to the ignore echo "*" > .gitignore &&
t/t7508-status.sh +1 -1
@@ -1699,7 +1699,7 @@ test_expect_success 'setup slow status advice' ' EOF git add .gitignore && git commit -m "Add .gitignore" && - git config advice.statusuoption true + git config set advice.statusuoption true ) '
Signature · 1 line
2.47.1.398.g18e7475ebe
Quoted 10 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141(builtin/config: introduce "set" subcommand, 2024-05-06)we have the "set" subcommand for config. Since using the subcommand is more in-line with the modern interface, any advice should be promoting its usage. Change the disable advice message to use the subcommand instead. Change all uses of "git config advice" in the tests to use the subcommand.
Thanks, this version looks good to me!
Patrick
Quoted 9 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141(builtin/config: introduce "set" subcommand, 2024-05-06)we have the "set" subcommand for config. Since using the subcommand is more in-line with the modern interface, any advice should be promoting its usage. Change the disable advice message to use the subcommand instead.
It's very consistent to keep our messages updated with respect to changes in the user interface. So this patch is a step in the right direction. Thanks for working on this.
Quoted 2 lines
Change all uses of "git config advice" in the tests to use the subcommand.
Maybe this should be done in a separate patch.
Quoted 37 lines
Signed-off-by Bence Ferdinandy <[email protected]>---
Notes:
For the tests I just indiscriminately ran:
sed -i "s/git config advice\./git config set advice./" t[0-9]*.shv2: - fixed 3 hardcoded "git config advice" type messages
- made the motiviation more explicitadvice.c | 2 +- commit.c | 2 +- hook.c | 2 +- object-name.c | 2 +- t/t0018-advice.sh | 2 +- t/t3200-branch.sh | 2 +- t/t3404-rebase-interactive.sh | 6 +++--- t/t3501-revert-cherry-pick.sh | 2 +- t/t3507-cherry-pick-conflict.sh | 6 +++--- t/t3510-cherry-pick-sequence.sh | 2 +- t/t3511-cherry-pick-x.sh | 2 +- t/t3602-rm-sparse-checkout.sh | 2 +- t/t3700-add.sh | 6 +++--- t/t3705-add-sparse-checkout.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 ++-- t/t7004-tag.sh | 2 +- t/t7201-co.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- t/t7508-status.sh | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)advice.c +0
-0
advice.c static struct { · line 96
Quoted 5 lines
advice.c +1
-1@@ -93,7 +93,7 @@ static struct {static const char turn_off_instructions[] =N_ ("\n" -"Disable this message with \"git config advice.%s false\"" ); +"Disable this message with \"git config set advice.%s false\"" );
The main goal of this patch. Good.
commit.c static int read_graft_file(struct repository *r, const char *graft_file) · line 279
Quoted 13 lines
advice.c +0
-0static void vadvise (const char *advice,int display_instructions,const char *key,va_list params)commit.c +1
-1@@ -276,7 +276,7 @@ static int read_graft_file(struct repository *r, const char *graft_file)"to convert the grafts into replace refs.\n" "\n" "Turn this message off by running\n" - "\"git config advice.graftFileDeprecated false\"")); + "\"git config set advice.graftFileDeprecated false\""));
OK.
However, instead of solidifying this message, perhaps we could take advantage of advise_if_enabled() here. That way, we simplify the code a bit while we also automatically get the new help message, which you are already adjusting in advice.c.
hook.c const char *find_hook(struct repository *r, const char *name) · line 42
Quoted 13 lines
commit.c +0
-0while (!strbuf_getwholeline (&buf, fp,'\n' )) {/* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft =read_graft_line (&buf);hook.c +1
-1@@ -39,7 +39,7 @@ const char *find_hook(struct repository *r, const char *name) advise(_("The '%s' hook was ignored because " "it's not set as executable.\n" "You can disable this warning with " - "`git config advice.ignoredHook false`."), + "`git config set advice.ignoredHook false`."),
This message is more of a warning than advice. I don't think we want to use the same approach here as above, because:
hint: The 'foo' hook was ignored because it's not set as executable.
hint: Disable this message with [...]
looks weird.
So, your change is enough and right. OK.
object-name.c static int get_oid_basic(struct repository *r, const char *str, int len, · line 955
Quoted 13 lines
hook.c +0
-0path.buf); } }object-name.c +1
-1@@ -952,7 +952,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,"\n" "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" "examine these refs and maybe delete them. Turn this message off by\n" - "running \"git config advice.objectNameWarning false\""); + "running \"git config set advice.objectNameWarning false\"");
Here, however, I think we should also switch to advise_if_enabled().
[...]
The rest of the patch looks good. I think it's desirable to separate the changes in the advice messages from the uses of "git config set" in the tests, as I commented at the beginning of this message. But I don't have a strong opinion on it.
I'll reply to this message with the changes I've suggested about using advise_if_enabled(). If you agree with the changes, feel free to use them as you wish.
Rubén Justo (3):
advice: enhance detach_advice() to detach_advice_if_enabled()
commit: use advise_if_enabled() in read_graft_file()
object-name: advice to avoid refs that resemble hashes
advice.c | 8 +++----- advice.h | 2 +- builtin/checkout.c | 5 ++--- builtin/clone.c | 3 +-- commit.c | 17 +++++++---------- object-name.c | 9 ++++----- t/t1512-rev-parse-disambiguation.sh | 15 ++++++++++++++- 7 files changed, 32 insertions(+), 27 deletions(-)
PATCH 1/3 advice: enhance `detach_advice()` to `detach_advice_if_enabled()`
We have the detachedHead advice since 13be3e31f1 ("Reword 'detached HEAD' notification", 2010-01-29).
This advice is shown to the user in the detach_advice() function, and its only two clients verify beforehand if the advice is desired, in order to call the function accordingly.
The advise_if_enabled() API encapsulates some functionality that we can take advantage of:
- Checks if the advice is desired, using advice_enabled().
- Automatically adds help, when needed, on how to disable the
advice: "Turn off this advice by ...".
- Displays the message consistently with other advise messages, prefixing each line with 'hint:'.
Let's simplify the logic for the clients of detach_advice() by eliminating their need to decide whether to show the advice, bringing that decision into detach_advice(). Also, let's make the it use advice_if_enabled() to ensure consistency with other advice messages.
To better reflect the changes in the function let's rename it to detach_advice_if_enabled().
Finally, note that we have two tests in t7201 related to this advice:
"checkout to detach HEAD (with advice declined)" and "checkout a detach HEAD". They are unaffected by the change we're doing here, so it is not necessary to adjust them in this step.
--- advice.c | 8 +++----- advice.h | 2 +- builtin/checkout.c | 5 ++--- builtin/clone.c | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-)
advice.c +3 -5
@@ -272,7 +272,7 @@ void advise_on_updating_sparse_paths(struct string_list *pathspec_list) "* Disable or modify the sparsity rules.")); } -void detach_advice (const char *new_name) +void detach_advice_if_enabled (const char *new_name) {const char *fmt = _("Note: switching to '%s'.\n"
@@ -288,11 +288,9 @@ void detach_advice(const char *new_name)"\n" "Or undo this operation with:\n" "\n" -" git switch -\n" -"\n" - "Turn off this advice by setting config variable advice.detachedHead to false\n\n"); + " git switch -\n"); -fprintf (stderr, fmt, new_name); +advise_if_enabled (ADVICE_DETACHED_HEAD , fmt, new_name); }void advise_on_moving_dirty_path (struct string_list *pathspec_list)
advice.h +1 -1
@@ -79,7 +79,7 @@ void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void); void NORETURN die_ff_impossible(void);void advise_on_updating_sparse_paths (struct string_list *pathspec_list); -void detach_advice (const char *new_name); +void detach_advice_if_enabled (const char *new_name);void advise_on_moving_dirty_path (struct string_list *pathspec_list);#endif /* ADVICE_H */
builtin/checkout.c +2 -3
@@ -1009,9 +1009,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,NULL , REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);if (!opts->quiet) { -if (old_branch_info->path && -advice_enabled (ADVICE_DETACHED_HEAD ) && !opts->force_detach) -detach_advice (new_branch_info->name); +if (old_branch_info->path && !opts->force_detach) +detach_advice_if_enabled (new_branch_info->name);describe_detached_head (_ ("HEAD is now at" ), new_branch_info->commit); } }else if (new_branch_info->path) {/* Switch branches. */
builtin/clone.c +1 -2
@@ -752,8 +752,7 @@ static int checkout(int submodule_progress, int filter_submodules,return 0 ; }if (!strcmp (head,"HEAD" )) { -if (advice_enabled (ADVICE_DETACHED_HEAD )) -detach_advice (oid_to_hex (&oid)); +detach_advice_if_enabled (oid_to_hex (&oid));FREE_AND_NULL (head); }else {if (!starts_with (head,"refs/heads/" ))
Signature · 1 line
2.47.1.407.gf6b6eee3e5
PATCH 2/3 commit: use `advise_if_enabled()` in `read_graft_file()`
In reply to Rubén JustoWe have a deprecation notice in read_graft_file() since f9f99b3f7d (Deprecate support for .git/info/grafts, 2018-04-29).
This deprecation notice is shown using advice_enabled() plus advise().
Let's use the advise_if_enabled() API which combines the functionality of both APIs and offers some advantages, such as:
standardizing the presentation of the help on how to disable the advice.
The test we have in t6001 "show advice that grafts are deprecated" does not need to be adjusted due to the changes in this step.
--- commit.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
commit.c +7 -10
@@ -267,16 +267,13 @@ static int read_graft_file(struct repository *r, const char *graft_file)struct strbuf buf =STRBUF_INIT ;if (!fp)return -1 ; -if (!no_graft_file_deprecated_advice && -advice_enabled (ADVICE_GRAFT_FILE_DEPRECATED )) -advise (_ ("Support for <GIT_DIR>/info/grafts is deprecated\n" -"and will be removed in a future Git version.\n" -"\n" -"Please use \"git replace --convert-graft-file\"\n" -"to convert the grafts into replace refs.\n" -"\n" -"Turn this message off by running\n" -"\"git config advice.graftFileDeprecated false\"" )); +if (!no_graft_file_deprecated_advice) +advise_if_enabled (ADVICE_GRAFT_FILE_DEPRECATED , +_ ("Support for <GIT_DIR>/info/grafts is deprecated\n" +"and will be removed in a future Git version.\n" +"\n" +"Please use \"git replace --convert-graft-file\"\n" +"to convert the grafts into replace refs.\n" ));while (!strbuf_getwholeline (&buf, fp,'\n' )) {/* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft =read_graft_line (&buf);
Signature · 1 line
2.47.1.407.gf6b6eee3e5
PATCH 3/3 object-name: advice to avoid refs that resemble hashes
In reply to Rubén JustoIf we detect a reference resembling a hash, we advice the user to avoid using it and delete it.
Let's use the advise_if_enabled() API to display the advice with the aim of achieving simplicity and consistency in how the advice is presented.
While we're here, let's add some tests for this advice to gain visibility if we unintentionally make changes about it.
Finally, the change from const char* to const char[] is to avoid problems with "-Werror=format-security".
--- object-name.c | 9 ++++----- t/t1512-rev-parse-disambiguation.sh | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-)
object-name.c +4 -5
@@ -943,7 +943,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len, struct object_id *oid, unsigned int flags) {static const char *warn_msg ="refname '%.*s' is ambiguous." ; -static const char *object_name_msg =N_ ( +static const char object_name_msg[] =N_ ("Git normally never creates a ref that ends with 40 hex characters\n" "because it will be ignored when you just specify 40-hex. These refs\n" "may be created by mistake. For example,\n"
@@ -951,8 +951,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len," git switch -c $br $(git rev-parse ...)\n" "\n" "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" -"examine these refs and maybe delete them. Turn this message off by\n" - "running \"git config advice.objectNameWarning false\""); + "examine these refs and maybe delete them.");struct object_id tmp_oid;char *real_ref =NULL ;int refs_found =0 ;
@@ -964,8 +963,8 @@ static int get_oid_basic(struct repository *r, const char *str, int len, refs_found =repo_dwim_ref (r, str, len, &tmp_oid, &real_ref,0 );if (refs_found >0 ) {warning (warn_msg, len, str); -if (advice_enabled (ADVICE_OBJECT_NAME_WARNING )) -fprintf (stderr,"%s\n" ,_ (object_name_msg)); +advise_if_enabled (ADVICE_OBJECT_NAME_WARNING , + object_name_msg); }free (real_ref); }
t/t1512-rev-parse-disambiguation.sh +14 -1
@@ -371,13 +371,26 @@ test_expect_success 'rev-parse --disambiguate drops duplicates' ' test_cmp expect actual ' +test_expect_success 'ambiguous 40-hex ref (with advice declined)' ' + git config set advice.objectNameWarning false && + TREE=$(git mktree </dev/null) && + REF=$(git rev-parse HEAD) && + VAL=$(git commit-tree $TREE </dev/null) && + git update-ref refs/heads/$REF $VAL && + test $(git rev-parse $REF 2>err) = $REF && + grep "refname.*${REF}.*ambiguous" err && + test_grep ! hint: err +' + test_expect_success 'ambiguous 40-hex ref' ' + git config unset advice.objectNameWarning && TREE=$(git mktree </dev/null) && REF=$(git rev-parse HEAD) && VAL=$(git commit-tree $TREE </dev/null) && git update-ref refs/heads/$REF $VAL && test $(git rev-parse $REF 2>err) = $REF && - grep "refname.*${REF}.*ambiguous" err + grep "refname.*${REF}.*ambiguous" err && + test_grep hint: err ' test_expect_success 'ambiguous short sha1 ref' '
Signature · 1 line
2.47.1.407.gf6b6eee3e5
Thanks for taking a looking and the follow-up patches!
Quoted 12 lines · Rubén Justo
Quoted 9 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141(builtin/config: introduce "set" subcommand, 2024-05-06)we have the "set" subcommand for config. Since using the subcommand is more in-line with the modern interface, any advice should be promoting its usage. Change the disable advice message to use the subcommand instead.
Quoted 8 lines
It's very consistent to keep our messages updated with respect to changes in the user interface. So this patch is a step in the right direction. Thanks for working on this.
Quoted 2 lines
Change all uses of "git config advice" in the tests to use the subcommand.
Maybe this should be done in a separate patch.
So I was a bit lazy here, since sed changed both the expected test outputs and the usage, so that could certainly be split into two patches to be prudent.
Quoted 111 lines
Quoted 38 lines
Signed-off-by Bence Ferdinandy <[email protected]>---
Notes:
For the tests I just indiscriminately ran:
sed -i "s/git config advice\./git config set advice./" t[0-9]*.shv2: - fixed 3 hardcoded "git config advice" type messages
- made the motiviation more explicitadvice.c | 2 +- commit.c | 2 +- hook.c | 2 +- object-name.c | 2 +- t/t0018-advice.sh | 2 +- t/t3200-branch.sh | 2 +- t/t3404-rebase-interactive.sh | 6 +++--- t/t3501-revert-cherry-pick.sh | 2 +- t/t3507-cherry-pick-conflict.sh | 6 +++--- t/t3510-cherry-pick-sequence.sh | 2 +- t/t3511-cherry-pick-x.sh | 2 +- t/t3602-rm-sparse-checkout.sh | 2 +- t/t3700-add.sh | 6 +++--- t/t3705-add-sparse-checkout.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 ++-- t/t7004-tag.sh | 2 +- t/t7201-co.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- t/t7508-status.sh | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)advice.c +0
-0advice.c static struct { · line 96
Quoted 5 lines
advice.c +1
-1@@ -93,7 +93,7 @@ static struct {static const char turn_off_instructions[] =N_ ("\n" -"Disable this message with \"git config advice.%s false\"" ); +"Disable this message with \"git config set advice.%s false\"" );The main goal of this patch. Good.
commit.c static int read_graft_file(struct repository *r, const char *graft_file) · line 279
Quoted 13 lines
advice.c +0
-0static void vadvise (const char *advice,int display_instructions,const char *key,va_list params)commit.c +1
-1@@ -276,7 +276,7 @@ static int read_graft_file(struct repository *r, const char *graft_file)"to convert the grafts into replace refs.\n" "\n" "Turn this message off by running\n" - "\"git config advice.graftFileDeprecated false\"")); + "\"git config set advice.graftFileDeprecated false\""));OK.
However, instead of solidifying this message, perhaps we could take advantage of
advise_if_enabled()here. That way, we simplify the code a bit while we also automatically get the new help message, which you are already adjusting inadvice.c.hook.c const char *find_hook(struct repository *r, const char *name) · line 42
Quoted 13 lines
commit.c +0
-0while (!strbuf_getwholeline (&buf, fp,'\n' )) {/* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft =read_graft_line (&buf);hook.c +1
-1@@ -39,7 +39,7 @@ const char *find_hook(struct repository *r, const char *name) advise(_("The '%s' hook was ignored because " "it's not set as executable.\n" "You can disable this warning with " - "`git config advice.ignoredHook false`."), + "`git config set advice.ignoredHook false`."),This message is more of a warning than advice. I don't think we want to use the same approach here as above, because:
hint: The 'foo' hook was ignored because it's not set as executable.
hint: Disable this message with [...]looks weird.
So, your change is enough and right. OK.
object-name.c static int get_oid_basic(struct repository *r, const char *str, int len, · line 955
Quoted 13 lines
hook.c +0
-0path.buf); } }object-name.c +1
-1@@ -952,7 +952,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,"\n" "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" "examine these refs and maybe delete them. Turn this message off by\n" - "running \"git config advice.objectNameWarning false\""); + "running \"git config set advice.objectNameWarning false\"");Here, however, I think we should also switch to
advise_if_enabled().[...]
Quoted 8 lines
The rest of the patch looks good. I think it's desirable to separate the changes in the advice messages from the uses of "git config set" in the tests, as I commented at the beginning of this message. But I don't have a strong opinion on it.
I'll reply to this message with the changes I've suggested about using
advise_if_enabled(). If you agree with the changes, feel free to use them as you wish.
Imho my patch is a "no-brainer" in that it doesn't really change anything about code or behaviour, while what you sent does, so I think the best way to go with this would be to first just switch to config set with already existing stuff and then open up the question of changing them in a more meaningful way. In general of course it seems like a good idea to bring advice messages under one interface, but there's more in there that I don't think I could argue for or against with any confidence.
I'll send a v3 with the test usages changes split out.
Thanks,
Bence
Quoted 156 lines · Bence Ferdinandy
Thanks for taking a looking and the follow-up patches!
Quoted 12 lines · Rubén Justo
Quoted 9 lines · Bence Ferdinandy
The advice message currently suggests using "git config advice..." to disable advice messages, but since
00bbdde141(builtin/config: introduce "set" subcommand, 2024-05-06)we have the "set" subcommand for config. Since using the subcommand is more in-line with the modern interface, any advice should be promoting its usage. Change the disable advice message to use the subcommand instead.
Quoted 8 lines
It's very consistent to keep our messages updated with respect to changes in the user interface. So this patch is a step in the right direction. Thanks for working on this.
Quoted 2 lines
Change all uses of "git config advice" in the tests to use the subcommand.
Maybe this should be done in a separate patch.
So I was a bit lazy here, since sed changed both the expected test outputs and the usage, so that could certainly be split into two patches to be prudent.
Quoted 111 lines
Quoted 38 lines
Signed-off-by Bence Ferdinandy <[email protected]>---
Notes:
For the tests I just indiscriminately ran:
sed -i "s/git config advice\./git config set advice./" t[0-9]*.shv2: - fixed 3 hardcoded "git config advice" type messages
- made the motiviation more explicitadvice.c | 2 +- commit.c | 2 +- hook.c | 2 +- object-name.c | 2 +- t/t0018-advice.sh | 2 +- t/t3200-branch.sh | 2 +- t/t3404-rebase-interactive.sh | 6 +++--- t/t3501-revert-cherry-pick.sh | 2 +- t/t3507-cherry-pick-conflict.sh | 6 +++--- t/t3510-cherry-pick-sequence.sh | 2 +- t/t3511-cherry-pick-x.sh | 2 +- t/t3602-rm-sparse-checkout.sh | 2 +- t/t3700-add.sh | 6 +++--- t/t3705-add-sparse-checkout.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 ++-- t/t7004-tag.sh | 2 +- t/t7201-co.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- t/t7508-status.sh | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)advice.c +0
-0advice.c static struct { · line 96
Quoted 5 lines
advice.c +1
-1@@ -93,7 +93,7 @@ static struct {static const char turn_off_instructions[] =N_ ("\n" -"Disable this message with \"git config advice.%s false\"" ); +"Disable this message with \"git config set advice.%s false\"" );The main goal of this patch. Good.
commit.c static int read_graft_file(struct repository *r, const char *graft_file) · line 279
Quoted 13 lines
advice.c +0
-0static void vadvise (const char *advice,int display_instructions,const char *key,va_list params)commit.c +1
-1@@ -276,7 +276,7 @@ static int read_graft_file(struct repository *r, const char *graft_file)"to convert the grafts into replace refs.\n" "\n" "Turn this message off by running\n" - "\"git config advice.graftFileDeprecated false\"")); + "\"git config set advice.graftFileDeprecated false\""));OK.
However, instead of solidifying this message, perhaps we could take advantage of
advise_if_enabled()here. That way, we simplify the code a bit while we also automatically get the new help message, which you are already adjusting inadvice.c.hook.c const char *find_hook(struct repository *r, const char *name) · line 42
Quoted 13 lines
commit.c +0
-0while (!strbuf_getwholeline (&buf, fp,'\n' )) {/* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft =read_graft_line (&buf);hook.c +1
-1@@ -39,7 +39,7 @@ const char *find_hook(struct repository *r, const char *name) advise(_("The '%s' hook was ignored because " "it's not set as executable.\n" "You can disable this warning with " - "`git config advice.ignoredHook false`."), + "`git config set advice.ignoredHook false`."),This message is more of a warning than advice. I don't think we want to use the same approach here as above, because:
hint: The 'foo' hook was ignored because it's not set as executable.
hint: Disable this message with [...]looks weird.
So, your change is enough and right. OK.
object-name.c static int get_oid_basic(struct repository *r, const char *str, int len, · line 955
Quoted 13 lines
hook.c +0
-0path.buf); } }object-name.c +1
-1@@ -952,7 +952,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,"\n" "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" "examine these refs and maybe delete them. Turn this message off by\n" - "running \"git config advice.objectNameWarning false\""); + "running \"git config set advice.objectNameWarning false\"");Here, however, I think we should also switch to
advise_if_enabled().[...]
Quoted 8 lines
The rest of the patch looks good. I think it's desirable to separate the changes in the advice messages from the uses of "git config set" in the tests, as I commented at the beginning of this message. But I don't have a strong opinion on it.
I'll reply to this message with the changes I've suggested about using
advise_if_enabled(). If you agree with the changes, feel free to use them as you wish.Imho my patch is a "no-brainer" in that it doesn't really change anything about code or behaviour, while what you sent does, so I think the best way to go with this would be to first just switch to
config setwith already existing stuff and then open up the question of changing them in a more meaningful way. In general of course it seems like a good idea to bring advice messages under one interface, but there's more in there that I don't think I could argue for or against with any confidence.
Quoted 4 lines
I'll send a v3 with the test usages changes split out.
Thanks,
Bence
I started to split the commit, but realized that I only updated "git config advice\." to "git config set advice." in the tests. If I split the around five instances of actually using "git config advice" in the code, then it starts to make a lot less sense for why it is only for "advice" and not for all the other uses of "git config" in the tests. So I'm now inclined to think that I either leave the patch as is, or simple just remove the parts that are not updating expected test outcomes and leave updating usage of "git config" in tests for a later as it would likely be a larger effort to clean up everything to use explicit set/get. This cleanup would also only make sense if there are plans to deprecate the old implicit setting syntax at some point.
So should I remove the changes to usage in tests or just leave the patch as is?
Best,
Bence
Quoted 5 lines · Bence Ferdinandy
I started to split the commit, but realized that I only updated "git config advice\." to "git config set advice." in the tests. If I split the around five instances of actually using "git config advice" in the code, then it starts to make a lot less sense for why it is only for "advice" and not for all the other uses of "git config" in the tests.
If I understand the intention of this series correctly, the main goal is to update the help messages we give to the user on how to disable the advice messages. I think you have addressed that.
Updating the tests to use the new UI "git config set advice" sounds in this series, because it's related to the advice machinery.
Updating the test suite to use the new "git config" UI seems out of scope, I think.
Quoted 8 lines
So I'm now inclined to think that I either
leave the patch as is, or simple just remove the parts that are not updating expected test outcomes and leave updating usage of "git config" in tests for a later as it would likely be a larger effort to clean up everything to use explicit set/get. This cleanup would also only make sense if there are plans to deprecate the old implicit setting syntax at some point.So should I remove the changes to usage in tests or just leave the patch as is?
I don't have a strong opinion on this. Since my message, Junio has marked this series to be merged to "next". I can be perfectly happy with the patch as is.
On the other hand, perhaps I could send my patches about advise_if_enabled(), later, rebuilt on this series once the dust has settled.
On Mon Dec 09, 2024 at 21:35, Rubén Justo <[email protected]> wrote:
[snip]
Quoted 8 lines
I don't have a strong opinion on this. Since my message, Junio has marked this series to be merged to "next". I can be perfectly happy with the patch as is.
On the other hand, perhaps I could send my patches about
advise_if_enabled(), later, rebuilt on this series once the dust has settled.
I think that would be rather worthwhile, since having different mechanism for displaying advice isn't the best for sure. And it seems the patch has indeed made it to "next" recently, so I think it would be safe to rebuild on it now.
Thanks,
Bence
Quoted 8 lines · Bence Ferdinandy
On Mon Dec 09, 2024 at 21:35, Rubén Justo <[email protected]> wrote:
[snip]Quoted 5 lines
I don't have a strong opinion on this. Since my message, Junio has marked this series to be merged to "next". I can be perfectly happy with the patch as is.
Quoted 6 lines
Quoted 3 lines
On the other hand, perhaps I could send my patches about
advise_if_enabled(), later, rebuilt on this series once the dust has settled.I think that would be rather worthwhile, since having different mechanism for displaying advice isn't the best for sure.
Indeed.
Quoted 2 lines
And it seems the patch has indeed
made it to "next" recently, so I think it would be safe to rebuild on it now.
Yes. I'll wait a few days, and then I'll send it.
Thanks.
Quoted 9 lines · Patrick Steinhardt
Yeah. Overall I think it is fine to do an iterative transition to the new interface.
git config setis not going to be the only instance that needs changes, but I very much assume that we will have suggestions and warnings all over the place that may recommend other modes of the command like the equivalent ofgit config get. But these don't have to all happen in the same commit, or even the same patch series, from my point of view.Thanks for working on this!
Exactly. We may have to keep both old and new (more explicit) ways to spell the subcommand, and consistently using the new way in our documentation pages and instruction given in advice messages is a good thing, but it is more or less a clean-up effort we can do at leisure ;-) As long as we make sure we finish before we mark the old way deprecated, it is perfectly fine.
Thanks.