Merge branch 'jh/partial-clone'
[gitweb.git] / sideband.c
index 1e4d684d6c5dcdeee94f6eb64cfa6e2f17d44674..325bf0e974ab9bd8c2c5b5483fbb619ac425531b 100644 (file)
  * the remote died unexpectedly.  A flush() concludes the stream.
  */
 
-#define PREFIX "remote: "
+#define DISPLAY_PREFIX "remote: "
 
 #define ANSI_SUFFIX "\033[K"
 #define DUMB_SUFFIX "        "
 
 int recv_sideband(const char *me, int in_stream, int out)
 {
-       const char *term, *suffix;
+       const char *suffix;
        char buf[LARGE_PACKET_MAX + 1];
        struct strbuf outbuf = STRBUF_INIT;
        int retval = 0;
 
-       term = getenv("TERM");
-       if (isatty(2) && term && strcmp(term, "dumb"))
+       if (isatty(2) && !is_terminal_dumb())
                suffix = ANSI_SUFFIX;
        else
                suffix = DUMB_SUFFIX;
@@ -50,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int out)
                switch (band) {
                case 3:
                        strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
-                                   PREFIX, buf + 1);
+                                   DISPLAY_PREFIX, buf + 1);
                        retval = SIDEBAND_REMOTE_ERROR;
                        break;
                case 2:
@@ -68,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int out)
                                int linelen = brk - b;
 
                                if (!outbuf.len)
-                                       strbuf_addstr(&outbuf, PREFIX);
+                                       strbuf_addstr(&outbuf, DISPLAY_PREFIX);
                                if (linelen > 0) {
                                        strbuf_addf(&outbuf, "%.*s%s%c",
                                                    linelen, b, suffix, *brk);
@@ -82,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int out)
                        }
 
                        if (*b)
-                               strbuf_addf(&outbuf, "%s%s",
-                                           outbuf.len ? "" : PREFIX, b);
+                               strbuf_addf(&outbuf, "%s%s", outbuf.len ?
+                                           "" : DISPLAY_PREFIX, b);
                        break;
                case 1:
                        write_or_die(out, buf + 1, len);