Get fetch-depth:0 right.
[rsync.git] / usage.c
diff --git a/usage.c b/usage.c
index 84a94b82ab431b38a2989677acde7620fe6a490c..f346385f4015cfdd4a02695994ae027ab50bb4c8 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -172,14 +172,19 @@ static void print_info_flags(enum logcode f)
                else if (as_json) {
                        char *space = strchr(str, ' ');
                        int is_no = space && strncmp(str, "no ", 3) == 0;
-                       char *quot = space && !is_no ? "\"" : "";
+                       int is_bits = space && isDigit(str);
+                       char *quot = space && !is_no && !is_bits ? "\"" : "";
                        char *item = space ? space + 1 : str;
                        char *val = !space ? "true" : is_no ? "false" : str;
                        int val_len = !space ? 4 : is_no ? 5 : space - str;
+                       if (is_bits && (space = strchr(val, '-')) != NULL)
+                           val_len = space - str;
                        item_len = snprintf(item_buf, sizeof item_buf,
-                                          " \"%s\": %s%.*s%s%s", item, quot, val_len, val, quot,
-                                          need_comma ? "," : "");
-                       for (space = item; (space = strchr(space, ' ')) != NULL; space++)
+                                          " \"%s%s\": %s%.*s%s%s", item, is_bits ? "bits" : "",
+                                          quot, val_len, val, quot, need_comma ? "," : "");
+                       if (is_bits)
+                               item_buf[strlen(item)+2-1] = '_'; /* Turn the 's' into a '_' */
+                       for (space = item; (space = strpbrk(space, " -")) != NULL; space++)
                                item_buf[space - item + 2] = '_';
                } else
                        item_len = snprintf(item_buf, sizeof item_buf, " %s%s", str, need_comma ? "," : "");
@@ -260,7 +265,7 @@ void print_rsync_version(enum logcode f)
                char verbuf[32];
                json_line("program", RSYNC_NAME);
                json_line("version", rsync_version());
-               snprintf(verbuf, sizeof verbuf, "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION);
+               (void)snprintf(verbuf, sizeof verbuf, "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION);
                json_line("protocol", verbuf);
                json_line("copyright", copyright);
                json_line("url", url);
@@ -285,9 +290,10 @@ void print_rsync_version(enum logcode f)
        output_nno_list(f, "Daemon auth list", &valid_auth_checksums);
 
        if (f == FNONE) {
-               json_line("license", "GPL3");
+               json_line("license", "GPLv3");
                json_line("caveat", "rsync comes with ABSOLUTELY NO WARRANTY");
                printf("\n}\n");
+               fflush(stdout);
                return;
        }