2008-07-30 01:16:58 +02:00
|
|
|
#ifndef HELP_H
|
|
|
|
#define HELP_H
|
|
|
|
|
2018-05-26 15:55:24 +02:00
|
|
|
#include "string-list.h"
|
|
|
|
#include "strbuf.h"
|
2018-05-20 20:39:59 +02:00
|
|
|
|
2008-07-30 01:16:58 +02:00
|
|
|
struct cmdnames {
|
|
|
|
int alloc;
|
|
|
|
int cnt;
|
|
|
|
struct cmdname {
|
2008-08-31 15:50:23 +02:00
|
|
|
size_t len; /* also used for similarity index in help.c */
|
2008-07-30 01:16:58 +02:00
|
|
|
char name[FLEX_ARRAY];
|
|
|
|
} **names;
|
|
|
|
};
|
|
|
|
|
2008-08-02 10:08:38 +02:00
|
|
|
static inline void mput_char(char c, unsigned int num)
|
|
|
|
{
|
|
|
|
while(num--)
|
|
|
|
putchar(c);
|
|
|
|
}
|
|
|
|
|
2010-09-01 04:29:08 +02:00
|
|
|
extern void list_common_cmds_help(void);
|
2018-05-20 20:40:01 +02:00
|
|
|
extern void list_all_cmds_help(void);
|
2018-05-20 20:40:02 +02:00
|
|
|
extern void list_common_guides_help(void);
|
2018-05-26 15:55:28 +02:00
|
|
|
extern void list_config_help(int for_human);
|
2018-05-20 20:40:01 +02:00
|
|
|
|
2018-05-20 20:39:59 +02:00
|
|
|
extern void list_all_main_cmds(struct string_list *list);
|
|
|
|
extern void list_all_other_cmds(struct string_list *list);
|
2018-05-20 20:40:00 +02:00
|
|
|
extern void list_cmds_by_category(struct string_list *list,
|
|
|
|
const char *category);
|
2018-05-20 20:40:09 +02:00
|
|
|
extern void list_cmds_by_config(struct string_list *list);
|
2010-09-01 04:29:08 +02:00
|
|
|
extern const char *help_unknown_cmd(const char *cmd);
|
|
|
|
extern void load_command_list(const char *prefix,
|
|
|
|
struct cmdnames *main_cmds,
|
|
|
|
struct cmdnames *other_cmds);
|
|
|
|
extern void add_cmdname(struct cmdnames *cmds, const char *name, int len);
|
2008-07-30 01:16:58 +02:00
|
|
|
/* Here we require that excludes is a sorted list. */
|
2010-09-01 04:29:08 +02:00
|
|
|
extern void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
|
|
|
|
extern int is_in_cmdlist(struct cmdnames *cmds, const char *name);
|
2012-05-04 00:13:31 +02:00
|
|
|
extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdnames *other_cmds);
|
2008-07-30 01:16:58 +02:00
|
|
|
|
2013-05-04 02:04:19 +02:00
|
|
|
/*
|
|
|
|
* call this to die(), when it is suspected that the user mistyped a
|
|
|
|
* ref to the command, to give suggested "correct" refs.
|
|
|
|
*/
|
|
|
|
extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
|
2018-05-26 15:55:24 +02: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 14:51:08 +02:00
|
|
|
void list_config_color_sideband_slots(struct string_list *list, const char *prefix);
|
2018-05-26 15:55:24 +02:00
|
|
|
void list_config_fsck_msg_ids(struct string_list *list, const char *prefix);
|
|
|
|
|
2008-07-30 01:16:58 +02:00
|
|
|
#endif /* HELP_H */
|