branch: advice using git-help(1) instead of man(1)

8fbd903e (branch: advise about ref syntax rules, 2024-03-05) added an advice about checking git-check-ref-format(1) for the ref syntax rules. The advice uses man(1). But git(1) is a multi-platform tool and man(1) may not be available on some platforms. It might also be slightly jarring to see a suggestion for running a command which is not from the Git suite. Let’s instead use git-help(1) in order to stay inside the land of git(1). This also means that `help.format` (for `man`, `html` or other formats) will be used if set. Also change to using single quotes (') to quote the command since that is more conventional. While here let’s also update the test to use `{SQ}`, which is more readable and easier to edit. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristoffer Haugsbakk committed Dec 2, 2025 at 16:56 UTC b14f1df9f26cf87856cf6767847ccb4a5b31499b
3 files changed +5 -5
branch.c
+1 -1
@@ -375,7 +375,7 @@ int validate_branchname(const char *name, struct strbuf *ref)
375 if (check_branch_ref(ref, name)) {
376 int code = die_message(_("'%s' is not a valid branch name"), name);
377 advise_if_enabled(ADVICE_REF_SYNTAX,
378 - _("See `man git check-ref-format`"));
378 + _("See 'git help check-ref-format'"));
379 exit(code);
380 }
381
builtin/branch.c
+1 -1
@@ -591,7 +591,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
591 else {
592 int code = die_message(_("invalid branch name: '%s'"), oldname);
593 advise_if_enabled(ADVICE_REF_SYNTAX,
594 - _("See `man git check-ref-format`"));
594 + _("See 'git help check-ref-format'"));
595 exit(code);
596 }
597 }
t/t3200-branch.sh
+3 -3
@@ -1707,9 +1707,9 @@ test_expect_success '--track overrides branch.autoSetupMerge' '
1707 '
1708
1709 test_expect_success 'errors if given a bad branch name' '
1710 - cat <<-\EOF >expect &&
1711 - fatal: '\''foo..bar'\'' is not a valid branch name
1712 - hint: See `man git check-ref-format`
1710 + cat <<-EOF >expect &&
1711 + fatal: ${SQ}foo..bar${SQ} is not a valid branch name
1712 + hint: See ${SQ}git help check-ref-format${SQ}
1713 hint: Disable this message with "git config set advice.refSyntax false"
1714 EOF
1715 test_must_fail git branch foo..bar >actual 2>&1 &&