advice: give cut-and-pasteable advice to squelch
Advice messages that the advise_if_enabled() helper emits tell
the user how to squelch a particular piece of advice by setting a
configuration variable. The message it gives says:
hint: Disable this message with "git config set advice.FOO false"
However, cutting and pasting the given hint would set the
configuration variable in the per-repository configuration file
(which is the default behavior for 'git config set'). As the user
most likely sets it after seeing advice and understanding its
ramifications, the choice of squelching or continuing to see the
advice message is better controlled per-user, not per-repository.
In addition, some advice, such as advice.defaultBranchName, is
applicable only once before a new repository is created, so setting
it in the per-repository configuration file is far too late.
Add '--global' to the 'git config set' command line so that the
configuration is set for the user rather than per repository.
Initial-work-by: Vsevolod Myalitsin <ub4nal@mail.ru>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
seen
parent
fa7f9290ef
commit
6cbc556c76
2
advice.c
2
advice.c
|
|
@ -96,7 +96,7 @@ static struct {
|
|||
|
||||
static const char turn_off_instructions[] =
|
||||
N_("\n"
|
||||
"Disable this message with \"git config set advice.%s false\"");
|
||||
"Disable this message with \"git config set --global advice.%s false\"");
|
||||
|
||||
static void vadvise(const char *advice, int display_instructions,
|
||||
const char *key, va_list params)
|
||||
|
|
|
|||
|
|
@ -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 set advice.nestedTag false"
|
||||
hint: Disable this message with "git config set --global advice.nestedTag false"
|
||||
EOF
|
||||
test-tool advise "This is a piece of advice" 2>actual &&
|
||||
test_cmp expect actual
|
||||
|
|
|
|||
|
|
@ -1751,7 +1751,7 @@ test_expect_success 'errors if given a bad branch name' '
|
|||
cat <<-EOF >expect &&
|
||||
fatal: ${SQ}foo..bar${SQ} is not a valid branch name
|
||||
hint: See ${SQ}git help check-ref-format${SQ}
|
||||
hint: Disable this message with "git config set advice.refSyntax false"
|
||||
hint: Disable this message with "git config set --global advice.refSyntax false"
|
||||
EOF
|
||||
test_must_fail git branch foo..bar >actual 2>&1 &&
|
||||
test_cmp expect actual
|
||||
|
|
|
|||
|
|
@ -2341,20 +2341,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 set advice.rebaseTodoError false"
|
||||
hint: Disable this message with "git config set --global 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 set advice.rebaseTodoError false"
|
||||
hint: Disable this message with "git config set --global 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 set advice.rebaseTodoError false"
|
||||
hint: Disable this message with "git config set --global advice.rebaseTodoError false"
|
||||
error: invalid line 3: edit $oid
|
||||
error: cannot squash merge commit into another commit
|
||||
error: invalid line 4: fixup $oid
|
||||
|
|
|
|||
|
|
@ -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 set advice.mergeConflict false"
|
||||
hint: Disable this message with "git config set --global advice.mergeConflict false"
|
||||
EOF
|
||||
test_commit --append --no-tag "double-add dream" dream dream &&
|
||||
test_must_fail git revert HEAD^ 2>actual &&
|
||||
|
|
|
|||
|
|
@ -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 set advice.mergeConflict false"
|
||||
hint: Disable this message with "git config set --global 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 set advice.mergeConflict false\"
|
||||
hint: Disable this message with \"git config set --global advice.mergeConflict false\"
|
||||
EOF
|
||||
test_must_fail git cherry-pick --no-commit picked 2>actual &&
|
||||
|
||||
|
|
|
|||
|
|
@ -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 set advice.updateSparsePath false\"
|
||||
hint: Disable this message with \"git config set --global advice.updateSparsePath false\"
|
||||
EOF
|
||||
|
||||
echo b | cat sparse_error_header - >sparse_entry_b_error &&
|
||||
|
|
|
|||
|
|
@ -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 set advice.addEmptyPathspec false"
|
||||
hint: Disable this message with "git config set --global advice.addEmptyPathspec false"
|
||||
EOF
|
||||
git add 2>actual &&
|
||||
test_cmp expect actual
|
||||
|
|
@ -386,7 +386,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 set advice.addEmbeddedRepo false"
|
||||
hint: Disable this message with "git config set --global advice.addEmbeddedRepo false"
|
||||
warning: adding embedded git repository: inner2
|
||||
EOF
|
||||
test_cmp expect actual
|
||||
|
|
@ -425,7 +425,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 set advice.addIgnoredFile false"
|
||||
hint: Disable this message with "git config set --global advice.addIgnoredFile false"
|
||||
EOF
|
||||
cat >expect.out <<\EOF
|
||||
add 'track-this'
|
||||
|
|
|
|||
|
|
@ -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 set advice.updateSparsePath false\"
|
||||
hint: Disable this message with \"git config set --global advice.updateSparsePath false\"
|
||||
EOF
|
||||
|
||||
echo sparse_entry | cat sparse_error_header - >sparse_entry_error &&
|
||||
|
|
|
|||
|
|
@ -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 set advice.updateSparsePath false\"
|
||||
hint: Disable this message with \"git config set --global 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 set advice.updateSparsePath false\"
|
||||
hint: Disable this message with \"git config set --global advice.updateSparsePath false\"
|
||||
EOF
|
||||
"
|
||||
|
||||
|
|
|
|||
|
|
@ -1887,7 +1887,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 set advice.nestedTag false"
|
||||
hint: Disable this message with "git config set --global advice.nestedTag false"
|
||||
EOF
|
||||
git tag -m nested nested annotated-v4.0 2>actual &&
|
||||
test_cmp expect actual
|
||||
|
|
|
|||
|
|
@ -231,7 +231,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 set advice.addIgnoredFile false"
|
||||
hint: Disable this message with "git config set --global advice.addIgnoredFile false"
|
||||
EOF
|
||||
# Does not use test_commit due to the ignore
|
||||
echo "*" > .gitignore &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue