Skip to content

Commit

Permalink
rev-list: allow -<n> as shorthand for --max-count=<n>
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Wong authored and Junio C Hamano committed Feb 1, 2006
1 parent 3af0698 commit 8233340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ 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");
Expand Down
4 changes: 4 additions & 0 deletions rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ static int is_rev_argument(const char *arg)
};
const char **p = rev_args;

/* accept -<digit>, like traditional "head" */
if ((*arg == '-') && isdigit(arg[1]))
return 1;

for (;;) {
const char *str = *p++;
int len;
Expand Down

0 comments on commit 8233340

Please sign in to comment.