2008-07-30 03:16:58 +04:00
|
|
|
#ifndef HELP_H
|
|
|
|
#define HELP_H
|
|
|
|
|
2018-05-26 16:55:24 +03:00
|
|
|
#include "string-list.h"
|
|
|
|
#include "strbuf.h"
|
2018-05-20 21:39:59 +03:00
|
|
|
|
2008-07-30 03:16:58 +04:00
|
|
|
struct cmdnames {
|
|
|
|
int alloc;
|
|
|
|
int cnt;
|
|
|
|
struct cmdname {
|
2008-08-31 17:50:23 +04:00
|
|
|
size_t len; /* also used for similarity index in help.c */
|
2008-07-30 03:16:58 +04:00
|
|
|
char name[FLEX_ARRAY];
|
|
|
|
} **names;
|
|
|
|
};
|
|
|
|
|
2008-08-02 12:08:38 +04:00
|
|
|
static inline void mput_char(char c, unsigned int num)
|
|
|
|
{
|
2018-12-11 17:58:10 +03:00
|
|
|
while (num--)
|
2008-08-02 12:08:38 +04:00
|
|
|
putchar(c);
|
|
|
|
}
|
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
void list_common_cmds_help(void);
|
|
|
|
void list_all_cmds_help(void);
|
|
|
|
void list_common_guides_help(void);
|
|
|
|
void list_config_help(int for_human);
|
2018-05-20 21:40:01 +03:00
|
|
|
|
2019-04-29 11:28:14 +03:00
|
|
|
void list_all_main_cmds(struct string_list *list);
|
|
|
|
void list_all_other_cmds(struct string_list *list);
|
|
|
|
void list_cmds_by_category(struct string_list *list,
|
2019-04-29 11:28:23 +03:00
|
|
|
const char *category);
|
2019-04-29 11:28:14 +03:00
|
|
|
void list_cmds_by_config(struct string_list *list);
|
|
|
|
const char *help_unknown_cmd(const char *cmd);
|
|
|
|
void load_command_list(const char *prefix,
|
2019-04-29 11:28:23 +03:00
|
|
|
struct cmdnames *main_cmds,
|
|
|
|
struct cmdnames *other_cmds);
|
2019-04-29 11:28:14 +03:00
|
|
|
void add_cmdname(struct cmdnames *cmds, const char *name, int len);
|
2008-07-30 03:16:58 +04:00
|
|
|
/* Here we require that excludes is a sorted list. */
|
2019-04-29 11:28:14 +03:00
|
|
|
void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
|
|
|
|
int is_in_cmdlist(struct cmdnames *cmds, const char *name);
|
|
|
|
void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdnames *other_cmds);
|
2008-07-30 03:16:58 +04:00
|
|
|
|
2013-05-04 04:04:19 +04:00
|
|
|
/*
|
|
|
|
* call this to die(), when it is suspected that the user mistyped a
|
|
|
|
* ref to the command, to give suggested "correct" refs.
|
|
|
|
*/
|
2019-08-29 22:13:16 +03:00
|
|
|
NORETURN void help_unknown_ref(const char *ref, const char *cmd, const char *error);
|
2018-05-26 16:55:24 +03:00
|
|
|
|
|
|
|
static inline void list_config_item(struct string_list *list,
|
|
|
|
const char *prefix,
|
|
|
|
const char *str)
|
|
|
|
{
|
|
|
|
string_list_append_nodup(list, xstrfmt("%s.%s", prefix, str));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define define_list_config_array(array) \
|
|
|
|
void list_config_##array(struct string_list *list, const char *prefix) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < ARRAY_SIZE(array); i++) \
|
|
|
|
if (array[i]) \
|
|
|
|
list_config_item(list, prefix, array[i]); \
|
|
|
|
} \
|
|
|
|
struct string_list
|
|
|
|
|
|
|
|
#define define_list_config_array_extra(array, values) \
|
|
|
|
void list_config_##array(struct string_list *list, const char *prefix) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
static const char *extra[] = values; \
|
|
|
|
for (i = 0; i < ARRAY_SIZE(extra); i++) \
|
|
|
|
list_config_item(list, prefix, extra[i]); \
|
|
|
|
for (i = 0; i < ARRAY_SIZE(array); i++) \
|
|
|
|
if (array[i]) \
|
|
|
|
list_config_item(list, prefix, array[i]); \
|
|
|
|
} \
|
|
|
|
struct string_list
|
|
|
|
|
|
|
|
/* These are actually scattered over many C files */
|
|
|
|
void list_config_advices(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_branch_slots(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_decorate_slots(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_diff_slots(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_grep_slots(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_interactive_slots(struct string_list *list, const char *prefix);
|
|
|
|
void list_config_color_status_slots(struct string_list *list, const char *prefix);
|
sideband: highlight keywords in remote sideband output
The colorization is controlled with the config setting "color.remote".
Supported keywords are "error", "warning", "hint" and "success". They
are highlighted if they appear at the start of the line, which is
common in error messages, eg.
ERROR: commit is missing Change-Id
The Git push process itself prints lots of non-actionable messages
(eg. bandwidth statistics, object counters for different phases of the
process). This obscures actionable error messages that servers may
send back. Highlighting keywords in the sideband draws more attention
to those messages.
The background for this change is that Gerrit does server-side
processing to create or update code reviews, and actionable error
messages (eg. missing Change-Id) must be communicated back to the user
during the push. User research has shown that new users have trouble
seeing these messages.
The highlighting is done on the client rather than server side, so
servers don't have to grow capabilities to understand terminal escape
codes and terminal state. It also consistent with the current state
where Git is control of the local display (eg. prefixing messages with
"remote: ").
The highlighting can be configured using color.remote.<KEYWORD>
configuration settings. Since the keys are matched case insensitively,
we match the keywords case insensitively too.
Finally, this solution is backwards compatible: many servers already
prefix their messages with "error", and they will benefit from this
change without requiring a server update. By contrast, a server-side
solution would likely require plumbing the TERM variable through the
git protocol, so it would require changes to both server and client.
Helped-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-07 15:51:08 +03:00
|
|
|
void list_config_color_sideband_slots(struct string_list *list, const char *prefix);
|
2018-05-26 16:55:24 +03:00
|
|
|
void list_config_fsck_msg_ids(struct string_list *list, const char *prefix);
|
|
|
|
|
2008-07-30 03:16:58 +04:00
|
|
|
#endif /* HELP_H */
|