Skip to content

Commit

Permalink
git docs: add a category for user-facing file, repo and command UX
Browse files Browse the repository at this point in the history
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 f442f28 (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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
avar authored and gitster committed Aug 4, 2022
1 parent dba1e53 commit d976c51
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 9 deletions.
1 change: 1 addition & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
cmds-synchingrepositories.txt \
cmds-synchelpers.txt \
cmds-guide.txt \
cmds-userinterfaces.txt \
cmds-purehelpers.txt \
cmds-foreignscminterface.txt

Expand Down
14 changes: 14 additions & 0 deletions Documentation/git-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SYNOPSIS
'git help' [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]
'git help' [-g|--guides]
'git help' [-c|--config]
'git help' [--user-interfaces]

DESCRIPTION
-----------
Expand Down Expand Up @@ -69,6 +70,19 @@ OPTIONS
--guides::
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::
--info::
Display manual page for the command in the 'info' format. The
Expand Down
8 changes: 8 additions & 0 deletions Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ The following documentation pages are guides about Git concepts.

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
-----------------------
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,7 @@ check-docs::
sed -e '1,/^### command list/d' \
-e '/^#/d' \
-e '/guide$$/d' \
-e '/interfaces$$/d' \
-e 's/[ ].*//' \
-e 's/^/listed /' command-list.txt; \
$(MAKE) -C Documentation print-man1 | \
Expand Down
9 changes: 9 additions & 0 deletions builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static enum help_action {
HELP_ACTION_ALL = 1,
HELP_ACTION_GUIDES,
HELP_ACTION_CONFIG,
HELP_ACTION_USER_INTERFACES,
HELP_ACTION_CONFIG_FOR_COMPLETION,
HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,
} cmd_mode;
Expand All @@ -69,6 +70,9 @@ static struct option builtin_help_options[] = {

OPT_CMDMODE('g', "guides", &cmd_mode, N_("print list of useful 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"),
HELP_ACTION_CONFIG),
OPT_CMDMODE_F(0, "config-for-completion", &cmd_mode, "",
Expand All @@ -84,6 +88,7 @@ static const char * const builtin_help_usage[] = {
N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]"),
"git help [-g|--guides]",
"git help [-c|--config]",
"git help [--user-interfaces]",
NULL
};

Expand Down Expand Up @@ -654,6 +659,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)
opt_mode_usage(argc, "--config-for-completion", help_format);
list_config_help(SHOW_CONFIG_VARS);
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:
opt_mode_usage(argc, "--config-sections-for-completion",
help_format);
Expand Down
21 changes: 13 additions & 8 deletions command-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
# specified here, which can only have "guide" attribute and nothing
# 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 name category [category] [category]
git-add mainporcelain worktree
Expand Down Expand Up @@ -192,24 +197,24 @@ git-verify-tag ancillaryinterrogators
git-whatchanged ancillaryinterrogators complete
git-worktree mainporcelain
git-write-tree plumbingmanipulators
gitattributes guide
gitcli guide
gitattributes userinterfaces
gitcli userinterfaces
gitcore-tutorial guide
gitcredentials guide
gitcvs-migration guide
gitdiffcore guide
giteveryday guide
gitfaq guide
gitglossary guide
githooks guide
gitignore guide
githooks userinterfaces
gitignore userinterfaces
gitk mainporcelain
gitmailmap guide
gitmodules guide
gitmailmap userinterfaces
gitmodules userinterfaces
gitnamespaces guide
gitremote-helpers guide
gitrepository-layout guide
gitrevisions guide
gitrepository-layout userinterfaces
gitrevisions userinterfaces
gitsubmodules guide
gittutorial guide
gittutorial-2 guide
Expand Down
12 changes: 12 additions & 0 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static struct category_description main_categories[] = {
{ CAT_plumbinginterrogators, N_("Low-level Commands / Interrogators") },
{ CAT_synchingrepositories, N_("Low-level Commands / Syncing Repositories") },
{ CAT_purehelpers, N_("Low-level Commands / Internal Helpers") },
{ CAT_userinterfaces, N_("User-facing repository, command and file interfaces") },
{ 0, NULL }
};

Expand All @@ -48,6 +49,7 @@ static const char *drop_prefix(const char *name, uint32_t category)

switch (category) {
case CAT_guide:
case CAT_userinterfaces:
prefix = "git";
break;
default:
Expand Down Expand Up @@ -433,6 +435,16 @@ void list_guides_help(void)
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)
{
struct string_list *list = data;
Expand Down
1 change: 1 addition & 0 deletions help.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static inline void mput_char(char c, unsigned int num)
void list_common_cmds_help(void);
void list_all_cmds_help(int show_external_commands, int show_aliases);
void list_guides_help(void);
void list_user_interfaces_help(void);

void list_all_main_cmds(struct string_list *list);
void list_all_other_cmds(struct string_list *list);
Expand Down
12 changes: 11 additions & 1 deletion t/t0012-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ test_expect_success 'invalid usage' '
test_expect_code 129 git help -g add &&
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 --config-for-completion add &&
test_expect_code 129 git help --config-sections-for-completion add
Expand Down Expand Up @@ -104,9 +106,9 @@ test_expect_success 'git help' '
test_i18ngrep "^ commit " help.output &&
test_i18ngrep "^ fetch " help.output
'

test_expect_success 'git help -g' '
git help -g >help.output &&
test_i18ngrep "^ attributes " help.output &&
test_i18ngrep "^ everyday " help.output &&
test_i18ngrep "^ tutorial " help.output
'
Expand All @@ -127,6 +129,12 @@ test_expect_success 'git help succeeds without git.html' '
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' '
git help -c >help.output &&
cat >expect <<-\EOF &&
Expand Down Expand Up @@ -220,6 +228,8 @@ test_expect_success "'git help -a' section spacing" '
Low-level Commands / Syncing Repositories
Low-level Commands / Internal Helpers
User-facing repository, command and file interfaces
EOF
test_cmp expect actual
'
Expand Down

0 comments on commit d976c51

Please sign in to comment.