rev-list: allow -n<n> as shorthand for --max-count=<n>
Both -n<n> and -n <n> are supported. POSIX versions of head(1) and tail(1) allow their line limits to be parsed this way. I find --max-count to be a commonly used option, and also similar in spirit to head/tail, so I decided to make life easier on my worn out (and lazy :) fingers with this patch. 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:26 UTC
3af06987eb3c376e2f1cc6dfa9c9c510b9e228cf
2 files changed
+25
rev-list.c
+10
@@ -749,6 +749,16 @@ int main(int argc, const char **argv)
749
struct commit *commit;
750
unsigned char sha1[20];
751
752
+ if (!strcmp(arg, "-n")) {
753
+ if (++i >= argc)
754
+ die("-n requires an argument");
755
+ max_count = atoi(argv[i]);
756
+ continue;
757
+ }
758
+ if (!strncmp(arg,"-n",2)) {
759
+ max_count = atoi(arg + 2);
760
+ continue;
761
+ }
762
if (!strncmp(arg, "--max-count=", 12)) {
763
max_count = atoi(arg + 12);
764
continue;
rev-parse.c
+15
@@ -165,6 +165,21 @@ int main(int argc, char **argv)
165
show_file(arg);
166
continue;
167
}
168
+ if (!strcmp(arg,"-n")) {
169
+ if (++i >= argc)
170
+ die("-n requires an argument");
171
+ if ((filter & DO_FLAGS) && (filter & DO_REVS)) {
172
+ show(arg);
173
+ show(argv[i]);
174
+ }
175
+ continue;
176
+ }
177
+ if (!strncmp(arg,"-n",2)) {
178
+ if ((filter & DO_FLAGS) && (filter & DO_REVS))
179
+ show(arg);
180
+ continue;
181
+ }
182
+
183
if (*arg == '-') {
184
if (!strcmp(arg, "--")) {
185
as_is = 1;