git docs: add a category for user-facing file, repo and command UX

Create a new "Repository, command and file interfaces" section in the
main "git help git" manual page. Move things that belong under this
new criteria from the generic "Guides" section.

The "Guides" section was added in f442f28a81 (git.txt: add list of
guides, 2020-08-05). It makes sense to have e.g. "giteveryday(7)" and
"gitfaq(7)" listed under "Guides".

But placing e.g. "gitignore(5)" in it is stretching the meaning of
what a "guide" is, ideally that section should list things similar to
"giteveryday(7)" and "gitcore-tutorial(7)".

An alternate name that was considered for this new section was "User
formats", for consistency with the nomenclature used for man section 5
in general. My man(1) lists it as "File formats and conventions,
e.g. /etc/passwd".

So calling this "git help --formats" or "git help --user-formats"
would make sense for e.g. gitignore(5), but would be stretching it
somewhat for githooks(5), and would seem really suspect for the likes
of gitcli(7).

Let's instead pick a name that's closer to the generic term "User
interface", which is really what this documentation discusses: General
user-interface documentation that doesn't obviously belong elsewhere.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-08-04 18:28:33 +02:00 committed by Junio C Hamano
parent dba1e5392f
commit d976c5100f
9 changed files with 70 additions and 9 deletions

View File

@ -290,6 +290,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
cmds-synchingrepositories.txt \ cmds-synchingrepositories.txt \
cmds-synchelpers.txt \ cmds-synchelpers.txt \
cmds-guide.txt \ cmds-guide.txt \
cmds-userinterfaces.txt \
cmds-purehelpers.txt \ cmds-purehelpers.txt \
cmds-foreignscminterface.txt cmds-foreignscminterface.txt

View File

@ -12,6 +12,7 @@ SYNOPSIS
'git help' [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>] 'git help' [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]
'git help' [-g|--guides] 'git help' [-g|--guides]
'git help' [-c|--config] 'git help' [-c|--config]
'git help' [--user-interfaces]
DESCRIPTION DESCRIPTION
----------- -----------
@ -69,6 +70,19 @@ OPTIONS
--guides:: --guides::
Prints a list of the Git concept guides on the standard output. Prints a list of the Git concept guides on the standard output.
--user-interfaces::
Prints a list of the repository, command and file interfaces
documentation on the standard output.
+
In-repository file interfaces such as `.git/info/exclude` are
documented here (see linkgit:gitrepository-layout[5]), as well as
in-tree configuration such as `.mailmap` (see linkgit:gitmailmap[5]).
+
This section of the documentation also covers general or widespread
user-interface conventions (e.g. linkgit:gitcli[7]), and
pseudo-configuration such as the file-based `.git/hooks/*` interface
described in linkgit:githooks[5].
-i:: -i::
--info:: --info::
Display manual page for the command in the 'info' format. The Display manual page for the command in the 'info' format. The

View File

@ -339,6 +339,14 @@ The following documentation pages are guides about Git concepts.
include::cmds-guide.txt[] include::cmds-guide.txt[]
Repository, command and file interfaces
---------------------------------------
This documentation discusses repository and command interfaces which
users are expected to interact with directly. See `--user-formats` in
linkgit:git-help[1] for more details on the critera.
include::cmds-userinterfaces.txt[]
Configuration Mechanism Configuration Mechanism
----------------------- -----------------------

View File

@ -3532,6 +3532,7 @@ check-docs::
sed -e '1,/^### command list/d' \ sed -e '1,/^### command list/d' \
-e '/^#/d' \ -e '/^#/d' \
-e '/guide$$/d' \ -e '/guide$$/d' \
-e '/interfaces$$/d' \
-e 's/[ ].*//' \ -e 's/[ ].*//' \
-e 's/^/listed /' command-list.txt; \ -e 's/^/listed /' command-list.txt; \
$(MAKE) -C Documentation print-man1 | \ $(MAKE) -C Documentation print-man1 | \

View File

@ -43,6 +43,7 @@ static enum help_action {
HELP_ACTION_ALL = 1, HELP_ACTION_ALL = 1,
HELP_ACTION_GUIDES, HELP_ACTION_GUIDES,
HELP_ACTION_CONFIG, HELP_ACTION_CONFIG,
HELP_ACTION_USER_INTERFACES,
HELP_ACTION_CONFIG_FOR_COMPLETION, HELP_ACTION_CONFIG_FOR_COMPLETION,
HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,
} cmd_mode; } cmd_mode;
@ -69,6 +70,9 @@ static struct option builtin_help_options[] = {
OPT_CMDMODE('g', "guides", &cmd_mode, N_("print list of useful guides"), OPT_CMDMODE('g', "guides", &cmd_mode, N_("print list of useful guides"),
HELP_ACTION_GUIDES), HELP_ACTION_GUIDES),
OPT_CMDMODE(0, "user-interfaces", &cmd_mode,
N_("print list of user-facing repository, command and file interfaces"),
HELP_ACTION_USER_INTERFACES),
OPT_CMDMODE('c', "config", &cmd_mode, N_("print all configuration variable names"), OPT_CMDMODE('c', "config", &cmd_mode, N_("print all configuration variable names"),
HELP_ACTION_CONFIG), HELP_ACTION_CONFIG),
OPT_CMDMODE_F(0, "config-for-completion", &cmd_mode, "", OPT_CMDMODE_F(0, "config-for-completion", &cmd_mode, "",
@ -84,6 +88,7 @@ static const char * const builtin_help_usage[] = {
N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]"), N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]"),
"git help [-g|--guides]", "git help [-g|--guides]",
"git help [-c|--config]", "git help [-c|--config]",
"git help [--user-interfaces]",
NULL NULL
}; };
@ -654,6 +659,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)
opt_mode_usage(argc, "--config-for-completion", help_format); opt_mode_usage(argc, "--config-for-completion", help_format);
list_config_help(SHOW_CONFIG_VARS); list_config_help(SHOW_CONFIG_VARS);
return 0; return 0;
case HELP_ACTION_USER_INTERFACES:
opt_mode_usage(argc, "--user-interfaces", help_format);
list_user_interfaces_help();
return 0;
case HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION: case HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION:
opt_mode_usage(argc, "--config-sections-for-completion", opt_mode_usage(argc, "--config-sections-for-completion",
help_format); help_format);

View File

@ -43,6 +43,11 @@
# specified here, which can only have "guide" attribute and nothing # specified here, which can only have "guide" attribute and nothing
# else. # else.
# #
# User-facing repository, command and file interfaces such as
# documentation for the .gitmodules, .mailmap etc. files lives in man
# sections 5 and 7. These entries can only have the "userinterfaces"
# attribute and nothing else.
#
### command list (do not change this line) ### command list (do not change this line)
# command name category [category] [category] # command name category [category] [category]
git-add mainporcelain worktree git-add mainporcelain worktree
@ -192,8 +197,8 @@ git-verify-tag ancillaryinterrogators
git-whatchanged ancillaryinterrogators complete git-whatchanged ancillaryinterrogators complete
git-worktree mainporcelain git-worktree mainporcelain
git-write-tree plumbingmanipulators git-write-tree plumbingmanipulators
gitattributes guide gitattributes userinterfaces
gitcli guide gitcli userinterfaces
gitcore-tutorial guide gitcore-tutorial guide
gitcredentials guide gitcredentials guide
gitcvs-migration guide gitcvs-migration guide
@ -201,15 +206,15 @@ gitdiffcore guide
giteveryday guide giteveryday guide
gitfaq guide gitfaq guide
gitglossary guide gitglossary guide
githooks guide githooks userinterfaces
gitignore guide gitignore userinterfaces
gitk mainporcelain gitk mainporcelain
gitmailmap guide gitmailmap userinterfaces
gitmodules guide gitmodules userinterfaces
gitnamespaces guide gitnamespaces guide
gitremote-helpers guide gitremote-helpers guide
gitrepository-layout guide gitrepository-layout userinterfaces
gitrevisions guide gitrevisions userinterfaces
gitsubmodules guide gitsubmodules guide
gittutorial guide gittutorial guide
gittutorial-2 guide gittutorial-2 guide

12
help.c
View File

@ -38,6 +38,7 @@ static struct category_description main_categories[] = {
{ CAT_plumbinginterrogators, N_("Low-level Commands / Interrogators") }, { CAT_plumbinginterrogators, N_("Low-level Commands / Interrogators") },
{ CAT_synchingrepositories, N_("Low-level Commands / Syncing Repositories") }, { CAT_synchingrepositories, N_("Low-level Commands / Syncing Repositories") },
{ CAT_purehelpers, N_("Low-level Commands / Internal Helpers") }, { CAT_purehelpers, N_("Low-level Commands / Internal Helpers") },
{ CAT_userinterfaces, N_("User-facing repository, command and file interfaces") },
{ 0, NULL } { 0, NULL }
}; };
@ -48,6 +49,7 @@ static const char *drop_prefix(const char *name, uint32_t category)
switch (category) { switch (category) {
case CAT_guide: case CAT_guide:
case CAT_userinterfaces:
prefix = "git"; prefix = "git";
break; break;
default: default:
@ -433,6 +435,16 @@ void list_guides_help(void)
putchar('\n'); putchar('\n');
} }
void list_user_interfaces_help(void)
{
struct category_description catdesc[] = {
{ CAT_userinterfaces, N_("User-facing repository, command and file interfaces:") },
{ 0, NULL }
};
print_cmd_by_category(catdesc, NULL);
putchar('\n');
}
static int get_alias(const char *var, const char *value, void *data) static int get_alias(const char *var, const char *value, void *data)
{ {
struct string_list *list = data; struct string_list *list = data;

1
help.h
View File

@ -22,6 +22,7 @@ static inline void mput_char(char c, unsigned int num)
void list_common_cmds_help(void); void list_common_cmds_help(void);
void list_all_cmds_help(int show_external_commands, int show_aliases); void list_all_cmds_help(int show_external_commands, int show_aliases);
void list_guides_help(void); void list_guides_help(void);
void list_user_interfaces_help(void);
void list_all_main_cmds(struct string_list *list); void list_all_main_cmds(struct string_list *list);
void list_all_other_cmds(struct string_list *list); void list_all_other_cmds(struct string_list *list);

View File

@ -44,6 +44,8 @@ test_expect_success 'invalid usage' '
test_expect_code 129 git help -g add && test_expect_code 129 git help -g add &&
test_expect_code 129 git help -a -g && test_expect_code 129 git help -a -g &&
test_expect_code 129 git help --user-interfaces add &&
test_expect_code 129 git help -g -c && test_expect_code 129 git help -g -c &&
test_expect_code 129 git help --config-for-completion add && test_expect_code 129 git help --config-for-completion add &&
test_expect_code 129 git help --config-sections-for-completion add test_expect_code 129 git help --config-sections-for-completion add
@ -104,9 +106,9 @@ test_expect_success 'git help' '
test_i18ngrep "^ commit " help.output && test_i18ngrep "^ commit " help.output &&
test_i18ngrep "^ fetch " help.output test_i18ngrep "^ fetch " help.output
' '
test_expect_success 'git help -g' ' test_expect_success 'git help -g' '
git help -g >help.output && git help -g >help.output &&
test_i18ngrep "^ attributes " help.output &&
test_i18ngrep "^ everyday " help.output && test_i18ngrep "^ everyday " help.output &&
test_i18ngrep "^ tutorial " help.output test_i18ngrep "^ tutorial " help.output
' '
@ -127,6 +129,12 @@ test_expect_success 'git help succeeds without git.html' '
test_cmp expect test-browser.log test_cmp expect test-browser.log
' '
test_expect_success 'git help --user-interfaces' '
git help --user-interfaces >help.output &&
grep "^ attributes " help.output &&
grep "^ mailmap " help.output
'
test_expect_success 'git help -c' ' test_expect_success 'git help -c' '
git help -c >help.output && git help -c >help.output &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
@ -220,6 +228,8 @@ test_expect_success "'git help -a' section spacing" '
Low-level Commands / Syncing Repositories Low-level Commands / Syncing Repositories
Low-level Commands / Internal Helpers Low-level Commands / Internal Helpers
User-facing repository, command and file interfaces
EOF EOF
test_cmp expect actual test_cmp expect actual
' '