@matheusbsbs / matheus-bagliano / commits / 8233340ce6
Fork 0

rev-list: allow -<n> as shorthand for --max-count=<n>

This builds on top of the previous one. Traditionally, head(1) and tail(1) allow their line limits to be parsed this way. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Jan 29, 2006 at 16:28 UTC 8233340ce6eb700eb2cd9c0fef4d1705997c499b
2 files changed +9
rev-list.c
+5
@@ -749,6 +749,11 @@ int main(int argc, const char **argv)
749 struct commit *commit;
750 unsigned char sha1[20];
751
752 + /* accept -<digit>, like traditilnal "head" */
753 + if ((*arg == '-') && isdigit(arg[1])) {
754 + max_count = atoi(arg + 1);
755 + continue;
756 + }
757 if (!strcmp(arg, "-n")) {
758 if (++i >= argc)
759 die("-n requires an argument");
rev-parse.c
+4
@@ -53,6 +53,10 @@ static int is_rev_argument(const char *arg)
53 };
54 const char **p = rev_args;
55
56 + /* accept -<digit>, like traditional "head" */
57 + if ((*arg == '-') && isdigit(arg[1]))
58 + return 1;
59 +
60 for (;;) {
61 const char *str = *p++;
62 int len;