branch: advice using git-help(1) instead of man(1)
PATCH 1/1 branch: advice using git-help(1) instead of man(1)
From: Kristoffer Haugsbakk <[email protected]>
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). It’s better to use Git’s own git-help(1) instead of an external command.
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.
--- branch.c | 2 +- builtin/branch.c | 2 +- t/t3200-branch.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
branch.c +1 -1
@@ -375,7 +375,7 @@ int validate_branchname(const char *name, struct strbuf *ref)if (check_branch_ref (ref, name)) {int code =die_message (_ ("'%s' is not a valid branch name" ), name);advise_if_enabled (ADVICE_REF_SYNTAX , -_ ("See `man git check-ref-format`" )); +_ ("See 'git help check-ref-format'" ));exit (code); }
builtin/branch.c +1 -1
@@ -591,7 +591,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, intelse {int code =die_message (_ ("invalid branch name: '%s'" ), oldname);advise_if_enabled (ADVICE_REF_SYNTAX , -_ ("See `man git check-ref-format`" )); +_ ("See 'git help check-ref-format'" ));exit (code); } }
t/t3200-branch.sh +3 -3
@@ -1707,9 +1707,9 @@ test_expect_success '--track overrides branch.autoSetupMerge' ' ' 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` + 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" EOF test_must_fail git branch foo..bar >actual 2>&1 &&
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
Signature · 1 line
2.52.0.10.g08704017180
Quoted 6 lines · [email protected] writes:
From: Kristoffer Haugsbakk <[email protected]>
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). It’s better to use Git’s own git-help(1) instead of an external command.
Substatiate "better" a bit better? If there were a universal help facility, we wouldn't have had to invent our own, and that would have been even better, but since we do not live in such an ideal world, we cater to people who live in a man-less land by having our own.
In other words, "An external command" is not the issue. Some people living in a man-less land is.
... for the ref syntax rules and refers to the man(1) command, which may not be available on some platforms. Refer to 'git help' instead.
Quoted 2 lines
Also change to using single quotes (') to quote the command since that is more conventional.
Yup. We haven't added markdown or asciidoc interpreter to our advise() machinery ;-)
Quoted 2 lines · Junio C Hamano
In other words, "An external command" is not the issue. Some people living in a man-less land is.
Another is that a user with access to "man" may prefer "html" (with "git help -w" or "help.format"). So this is only ...
Quoted 3 lines
... for the ref syntax rules and refers to the man(1) command, which may not be available on some platforms. Refer to 'git help' instead.
... half a story.
... which may not be available on some platforms, or which the user may prefer less. Refer to 'git help' instead.
Quoted 15 lines · Junio C Hamano
Quoted 6 lines · [email protected] writes:
From: Kristoffer Haugsbakk <[email protected]>
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). It’s better to use Git’s own git-help(1) instead of an external command.Substatiate "better" a bit better? If there were a universal help facility, we wouldn't have had to invent our own, and that would have been even better, but since we do not live in such an ideal world, we cater to people who live in a man-less land by having our own.
Quoted 6 lines
In other words, "An external command" is not the issue. Some people living in a man-less land is.
... for the ref syntax rules and refers to the man(1) command, which may not be available on some platforms. Refer to 'git help' instead.
I thought that’s what I did. This is output from git(1), not from a Debian/Ubuntu/Arch Linux distribution.
But people who only use Mac/Linux/(BSDs?) might not necessarily consider this point. So I’ll make it clearer.
PATCH v2 1/1 branch: advice using git-help(1) instead of man(1)
In reply to [email protected]From: Kristoffer Haugsbakk <[email protected]>
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.
---
Notes (series):
v2:
Improve commit message by expanding on why we want git-help(1) over man(1) according to feedback from <[email protected]>.
See this part:
> But git(1) is a multi-platform tool and man(1) may not be available on > some platforms.
This is according to the feedback from that email. But is that really true when e.g. Git For Windows bundles a Linux subsystem with Git Bash?
branch.c | 2 +- builtin/branch.c | 2 +- t/t3200-branch.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
branch.c +1 -1
@@ -375,7 +375,7 @@ int validate_branchname(const char *name, struct strbuf *ref)if (check_branch_ref (ref, name)) {int code =die_message (_ ("'%s' is not a valid branch name" ), name);advise_if_enabled (ADVICE_REF_SYNTAX , -_ ("See `man git check-ref-format`" )); +_ ("See 'git help check-ref-format'" ));exit (code); }
builtin/branch.c +1 -1
@@ -591,7 +591,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, intelse {int code =die_message (_ ("invalid branch name: '%s'" ), oldname);advise_if_enabled (ADVICE_REF_SYNTAX , -_ ("See `man git check-ref-format`" )); +_ ("See 'git help check-ref-format'" ));exit (code); } }
t/t3200-branch.sh +3 -3
@@ -1707,9 +1707,9 @@ test_expect_success '--track overrides branch.autoSetupMerge' ' ' 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` + 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" EOF test_must_fail git branch foo..bar >actual 2>&1 &&
Interdiff against v1:
Range-diff against v1:
1: 057269c683b ! 1: 8904bb016de branch: advice using git-help(1) instead of man(1)
@@ Commit message
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). It’s better to use Git’s own git-help(1)
- instead of an external command.
+ 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.
@@ Commit message
+
+ ## Notes (series) ##
+ v2:
+
+ Improve commit message by expanding on why we want git-help(1) over man(1)
+ according to feedback from <[email protected]>.
+
+ See this part:
+
+ > But git(1) is a multi-platform tool and man(1) may not be available on
+ > some platforms.
+
+ This is according to the feedback from that email. But is that really true
+ when e.g. Git For Windows bundles a Linux subsystem with Git Bash?
+
## branch.c ##
@@ branch.c: int validate_branchname(const char *name, struct strbuf *ref)
if (check_branch_ref(ref, name)) {
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
Signature · 1 line
2.52.0.10.g08704017180