rev-list: allow -n<n> as shorthand for --max-count=<n>
[git.git] / rev-parse.c
index a1aa863..3c99a79 100644 (file)
@@ -165,6 +165,21 @@ int main(int argc, char **argv)
                        show_file(arg);
                        continue;
                }
+               if (!strcmp(arg,"-n")) {
+                       if (++i >= argc)
+                               die("-n requires an argument");
+                       if ((filter & DO_FLAGS) && (filter & DO_REVS)) {
+                               show(arg);
+                               show(argv[i]);
+                       }
+                       continue;
+               }
+               if (!strncmp(arg,"-n",2)) {
+                       if ((filter & DO_FLAGS) && (filter & DO_REVS))
+                               show(arg);
+                       continue;
+               }
+
                if (*arg == '-') {
                        if (!strcmp(arg, "--")) {
                                as_is = 1;
@@ -310,7 +325,9 @@ int main(int argc, char **argv)
                }
                if (verify)
                        die("Needed a single revision");
-               if (lstat(arg, &st) < 0)
+               if ((filter & DO_REVS) &&
+                   (filter & DO_NONFLAGS) && /* !def && */
+                   lstat(arg, &st) < 0)
                        die("'%s': %s", arg, strerror(errno));
                as_is = 1;
                show_file(arg);