19
#include "sigchain.h"
20
#include "transport-internal.h"
21
#include "object-store.h"
22
+#include "color.h"
23
+
24
+static int transport_use_color = -1;
25
+static char transport_colors[][COLOR_MAXLEN] = {
26
+ GIT_COLOR_RESET,
27
+ GIT_COLOR_RED /* REJECTED */
28
+};
29
+
30
+enum color_transport {
31
+ TRANSPORT_COLOR_RESET = 0,
32
+ TRANSPORT_COLOR_REJECTED = 1
33
+};
34
+
35
+static int transport_color_config(void)
36
+{
37
+ const char *keys[] = {
38
+ "color.transport.reset",
39
+ "color.transport.rejected"
40
+ }, *key = "color.transport";
41
+ char *value;
42
+ int i;
43
+ static int initialized;
44
+
45
+ if (initialized)
46
+ return 0;
47
+ initialized = 1;
48
+
49
+ if (!git_config_get_string(key, &value))
50
+ transport_use_color = git_config_colorbool(key, value);
51
+
52
+ if (!want_color_stderr(transport_use_color))
53
+ return 0;
54
+
55
+ for (i = 0; i < ARRAY_SIZE(keys); i++)
56
+ if (!git_config_get_string(keys[i], &value)) {
57
+ if (!value)
58
+ return config_error_nonbool(keys[i]);
59
+ if (color_parse(value, transport_colors[i]) < 0)
60
+ return -1;
61
+ }
62
+
63
+ return 0;
64
+}
65
+
66
+static const char *transport_get_color(enum color_transport ix)
67
+{
68
+ if (want_color_stderr(transport_use_color))
69
+ return transport_colors[ix];
70
+ return "";
71
+}
72
73
static void set_upstreams(struct transport *transport, struct ref *refs,
74
int pretend)
389
else
390
fprintf(stdout, "%s\n", summary);
391
} else {
342
- fprintf(stderr, " %c %-*s ", flag, summary_width, summary);
392
+ const char *red = "", *reset = "";
393
+ if (push_had_errors(to)) {
394
+ red = transport_get_color(TRANSPORT_COLOR_REJECTED);
395
+ reset = transport_get_color(TRANSPORT_COLOR_RESET);
396
+ }
397
+ fprintf(stderr, " %s%c %-*s%s ", red, flag, summary_width,
398
+ summary, reset);
399
if (from)
400
fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
401
else
544
char *head;
545
int summary_width = transport_summary_width(refs);
546
547
+ if (transport_color_config() < 0)
548
+ warning(_("could not parse transport.color.* config"));
549
+
550
head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
551
552
if (verbose) {
613
struct send_pack_args args;
614
int ret;
615
616
+ if (transport_color_config() < 0)
617
+ return -1;
618
+
619
if (!data->got_remote_heads) {
620
struct ref *tmp_refs;
621
connect_setup(transport, 1);
1060
*reject_reasons = 0;
1061
transport_verify_remote_names(refspec_nr, refspec);
1062
1063
+ if (transport_color_config() < 0)
1064
+ return -1;
1065
+
1066
if (transport->vtable->push_refs) {
1067
struct ref *remote_refs;
1068
struct ref *local_refs = get_local_heads();