Merge branch 'sb/show-ref-parse-options'
[gitweb.git] / builtin-name-rev.c
index ff7d638dc2b71c9c29441b842b49ccf03a9b4618..06a38ac8c10126085e6477c205d450da089faae2 100644 (file)
@@ -172,7 +172,7 @@ static void show_name(const struct object *obj,
 }
 
 static char const * const name_rev_usage[] = {
-       "git-name-rev [options] ( --all | --stdin | <commit>... )",
+       "git name-rev [options] ( --all | --stdin | <commit>... )",
        NULL
 };
 
@@ -189,6 +189,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
                        unsigned char sha1[40];
                        const char *name = NULL;
                        char c = *(p+1);
+                       int p_len = p - p_start + 1;
 
                        forty = 0;
 
@@ -204,13 +205,10 @@ static void name_rev_line(char *p, struct name_ref_data *data)
                        if (!name)
                                continue;
 
-                       if (data->name_only) {
-                               fwrite(p_start, p - p_start + 1 - 40, 1, stdout);
-                               printf(name);
-                       } else {
-                               fwrite(p_start, p - p_start + 1, 1, stdout);
-                               printf(" (%s)", name);
-                       }
+                       if (data->name_only)
+                               printf("%.*s%s", p_len - 40, p_start, name);
+                       else
+                               printf("%.*s (%s)", p_len, p_start, name);
                        p_start = p + 1;
                }
        }
@@ -240,7 +238,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
        };
 
        git_config(git_default_config, NULL);
-       argc = parse_options(argc, argv, opts, name_rev_usage, 0);
+       argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
        if (!!all + !!transform_stdin + !!argc > 1) {
                error("Specify either a list, or --all, not both!");
                usage_with_options(name_rev_usage, opts);