rev-list: allow -<n> as shorthand for --max-count=<n>
[git.git] / rev-list.c
index 7d3ddc6..1bc1887 100644 (file)
@@ -21,6 +21,7 @@ static const char rev_list_usage[] =
 "    --min-age=epoch\n"
 "    --sparse\n"
 "    --no-merges\n"
+"    --remove-empty\n"
 "    --all\n"
 "  ordering output:\n"
 "    --merge-order [ --show-breaks ]\n"
@@ -82,7 +83,7 @@ static void show_commit(struct commit *commit)
 
        if (verbose_header) {
                static char pretty_header[16384];
-               pretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header));
+               pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), 0);
                printf("%s%c", pretty_header, hdr_termination);
        }
        fflush(stdout);
@@ -748,6 +749,21 @@ int main(int argc, const char **argv)
                struct commit *commit;
                unsigned char sha1[20];
 
+               /* accept -<digit>, like traditilnal "head" */
+               if ((*arg == '-') && isdigit(arg[1])) {
+                       max_count = atoi(arg + 1);
+                       continue;
+               }
+               if (!strcmp(arg, "-n")) {
+                       if (++i >= argc)
+                               die("-n requires an argument");
+                       max_count = atoi(argv[i]);
+                       continue;
+               }
+               if (!strncmp(arg,"-n",2)) {
+                       max_count = atoi(arg + 2);
+                       continue;
+               }
                if (!strncmp(arg, "--max-count=", 12)) {
                        max_count = atoi(arg + 12);
                        continue;