shortlog: fix "-n"
Since it is now a builtin optionally taking a range, we have to parse the options before the rev machinery, to be able to shadow the short hand "-n" for "--max-count". Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
549652361b
commit
6d6ab6104a
@ -15,11 +15,11 @@ static int compare_by_number(const void *a1, const void *a2)
|
|||||||
const struct path_list *l1 = i1->util, *l2 = i2->util;
|
const struct path_list *l1 = i1->util, *l2 = i2->util;
|
||||||
|
|
||||||
if (l1->nr < l2->nr)
|
if (l1->nr < l2->nr)
|
||||||
return -1;
|
return 1;
|
||||||
else if (l1->nr == l2->nr)
|
else if (l1->nr == l2->nr)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return +1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct path_list mailmap = {NULL, 0, 0, 0};
|
static struct path_list mailmap = {NULL, 0, 0, 0};
|
||||||
@ -251,8 +251,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
|
|||||||
struct path_list list = { NULL, 0, 0, 1 };
|
struct path_list list = { NULL, 0, 0, 1 };
|
||||||
int i, j, sort_by_number = 0, summary = 0;
|
int i, j, sort_by_number = 0, summary = 0;
|
||||||
|
|
||||||
init_revisions(&rev, prefix);
|
/* since -n is a shadowed rev argument, parse our args first */
|
||||||
argc = setup_revisions(argc, argv, &rev, NULL);
|
|
||||||
while (argc > 1) {
|
while (argc > 1) {
|
||||||
if (!strcmp(argv[1], "-n") || !strcmp(argv[1], "--numbered"))
|
if (!strcmp(argv[1], "-n") || !strcmp(argv[1], "--numbered"))
|
||||||
sort_by_number = 1;
|
sort_by_number = 1;
|
||||||
@ -262,10 +261,14 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
|
|||||||
else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
|
else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
|
||||||
usage(shortlog_usage);
|
usage(shortlog_usage);
|
||||||
else
|
else
|
||||||
die ("unrecognized argument: %s", argv[1]);
|
break;
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
}
|
}
|
||||||
|
init_revisions(&rev, prefix);
|
||||||
|
argc = setup_revisions(argc, argv, &rev, NULL);
|
||||||
|
if (argc > 1)
|
||||||
|
die ("unrecognized argument: %s", argv[1]);
|
||||||
|
|
||||||
if (!access(".mailmap", R_OK))
|
if (!access(".mailmap", R_OK))
|
||||||
read_mailmap(".mailmap");
|
read_mailmap(".mailmap");
|
||||||
@ -278,7 +281,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
|
|||||||
get_from_rev(&rev, &list);
|
get_from_rev(&rev, &list);
|
||||||
|
|
||||||
if (sort_by_number)
|
if (sort_by_number)
|
||||||
qsort(list.items, sizeof(struct path_list_item), list.nr,
|
qsort(list.items, list.nr, sizeof(struct path_list_item),
|
||||||
compare_by_number);
|
compare_by_number);
|
||||||
|
|
||||||
for (i = 0; i < list.nr; i++) {
|
for (i = 0; i < list.nr; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user