зеркало из https://github.com/microsoft/git.git
sequencer: allow disabling conflict advice
Allow disabling the advice shown when a squencer operation results in a merge conflict through a new config 'advice.mergeConflict', which is named generically such that it can be used by other commands eventually. Remove that final '\n' in the first hunk in sequencer.c to avoid an otherwise empty 'hint: ' line before the line 'hint: Disable this message with "git config advice.mergeConflict false"' which is automatically added by 'advise_if_enabled'. Note that we use 'advise_if_enabled' for each message in the second hunk in sequencer.c, instead of using 'if (show_hints && advice_enabled(...)', because the former instructs the user how to disable the advice, which is more user-friendly. Update the tests accordingly. Note that the body of the second test in t3507-cherry-pick-conflict.sh is enclosed in double quotes, so we must escape them in the added line. Note that t5520-pull.sh, which checks that we display the advice for 'git rebase' (via 'git pull --rebase') does not have to be updated because it only greps for a specific line in the advice message. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
2953d95d40
Коммит
ec0300914b
|
@ -56,6 +56,8 @@ advice.*::
|
|||
Shown when the user's information is guessed from the
|
||||
system username and domain name, to tell the user how to
|
||||
set their identity configuration.
|
||||
mergeConflict::
|
||||
Shown when various commands stop because of conflicts.
|
||||
nestedTag::
|
||||
Shown when a user attempts to recursively tag a tag object.
|
||||
pushAlreadyExists::
|
||||
|
|
1
advice.c
1
advice.c
|
@ -57,6 +57,7 @@ static struct {
|
|||
[ADVICE_GRAFT_FILE_DEPRECATED] = { "graftFileDeprecated" },
|
||||
[ADVICE_IGNORED_HOOK] = { "ignoredHook" },
|
||||
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity" },
|
||||
[ADVICE_MERGE_CONFLICT] = { "mergeConflict" },
|
||||
[ADVICE_NESTED_TAG] = { "nestedTag" },
|
||||
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning" },
|
||||
[ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists" },
|
||||
|
|
1
advice.h
1
advice.h
|
@ -25,6 +25,7 @@ enum advice_type {
|
|||
ADVICE_GRAFT_FILE_DEPRECATED,
|
||||
ADVICE_IGNORED_HOOK,
|
||||
ADVICE_IMPLICIT_IDENTITY,
|
||||
ADVICE_MERGE_CONFLICT,
|
||||
ADVICE_NESTED_TAG,
|
||||
ADVICE_OBJECT_NAME_WARNING,
|
||||
ADVICE_PUSH_ALREADY_EXISTS,
|
||||
|
|
33
sequencer.c
33
sequencer.c
|
@ -467,7 +467,7 @@ static void print_advice(struct repository *r, int show_hint,
|
|||
char *msg = getenv("GIT_CHERRY_PICK_HELP");
|
||||
|
||||
if (msg) {
|
||||
advise("%s\n", msg);
|
||||
advise_if_enabled(ADVICE_MERGE_CONFLICT, "%s", msg);
|
||||
/*
|
||||
* A conflict has occurred but the porcelain
|
||||
* (typically rebase --interactive) wants to take care
|
||||
|
@ -480,22 +480,25 @@ static void print_advice(struct repository *r, int show_hint,
|
|||
|
||||
if (show_hint) {
|
||||
if (opts->no_commit)
|
||||
advise(_("after resolving the conflicts, mark the corrected paths\n"
|
||||
"with 'git add <paths>' or 'git rm <paths>'"));
|
||||
advise_if_enabled(ADVICE_MERGE_CONFLICT,
|
||||
_("after resolving the conflicts, mark the corrected paths\n"
|
||||
"with 'git add <paths>' or 'git rm <paths>'"));
|
||||
else if (opts->action == REPLAY_PICK)
|
||||
advise(_("After resolving the conflicts, mark them with\n"
|
||||
"\"git add/rm <pathspec>\", then run\n"
|
||||
"\"git cherry-pick --continue\".\n"
|
||||
"You can instead skip this commit with \"git cherry-pick --skip\".\n"
|
||||
"To abort and get back to the state before \"git cherry-pick\",\n"
|
||||
"run \"git cherry-pick --abort\"."));
|
||||
advise_if_enabled(ADVICE_MERGE_CONFLICT,
|
||||
_("After resolving the conflicts, mark them with\n"
|
||||
"\"git add/rm <pathspec>\", then run\n"
|
||||
"\"git cherry-pick --continue\".\n"
|
||||
"You can instead skip this commit with \"git cherry-pick --skip\".\n"
|
||||
"To abort and get back to the state before \"git cherry-pick\",\n"
|
||||
"run \"git cherry-pick --abort\"."));
|
||||
else if (opts->action == REPLAY_REVERT)
|
||||
advise(_("After resolving the conflicts, mark them with\n"
|
||||
"\"git add/rm <pathspec>\", then run\n"
|
||||
"\"git revert --continue\".\n"
|
||||
"You can instead skip this commit with \"git revert --skip\".\n"
|
||||
"To abort and get back to the state before \"git revert\",\n"
|
||||
"run \"git revert --abort\"."));
|
||||
advise_if_enabled(ADVICE_MERGE_CONFLICT,
|
||||
_("After resolving the conflicts, mark them with\n"
|
||||
"\"git add/rm <pathspec>\", then run\n"
|
||||
"\"git revert --continue\".\n"
|
||||
"You can instead skip this commit with \"git revert --skip\".\n"
|
||||
"To abort and get back to the state before \"git revert\",\n"
|
||||
"run \"git revert --abort\"."));
|
||||
else
|
||||
BUG("unexpected pick action in print_advice()");
|
||||
}
|
||||
|
|
|
@ -170,6 +170,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"
|
||||
EOF
|
||||
test_commit --append --no-tag "double-add dream" dream dream &&
|
||||
test_must_fail git revert HEAD^ 2>actual &&
|
||||
|
|
|
@ -60,6 +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"
|
||||
EOF
|
||||
test_must_fail git cherry-pick picked 2>actual &&
|
||||
|
||||
|
@ -74,6 +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\"
|
||||
EOF
|
||||
test_must_fail git cherry-pick --no-commit picked 2>actual &&
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче