Merge lt/revlist,jc/diff,jc/revparse,jc/abbrev
[git.git] / rev-parse.c
index 42969a6..d2f0864 100644 (file)
@@ -199,15 +199,17 @@ int main(int argc, char **argv)
                                verify = 1;
                                continue;
                        }
-                       if (!strcmp(arg, "--abbrev") ||
-                           !strncmp(arg, "--abbrev=", 9)) {
+                       if (!strcmp(arg, "--short") ||
+                           !strncmp(arg, "--short=", 9)) {
                                filter &= ~(DO_FLAGS|DO_NOREV);
                                verify = 1;
                                abbrev = DEFAULT_ABBREV;
                                if (arg[8] == '=')
                                        abbrev = strtoul(arg + 9, NULL, 10);
-                               if (abbrev < 0 || 40 <= abbrev)
-                                       abbrev = DEFAULT_ABBREV;
+                               if (abbrev < MINIMUM_ABBREV)
+                                       abbrev = MINIMUM_ABBREV;
+                               else if (40 <= abbrev)
+                                       abbrev = 40;
                                continue;
                        }
                        if (!strcmp(arg, "--sq")) {
@@ -308,7 +310,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);