shortlog: add grouping option

In preparation for adding more grouping types, let's refactor the
committer/author grouping code and add a user-facing option that binds
them together. In particular:

  - the main option is now "--group", to make it clear
    that the various group types are mutually exclusive. The
    "--committer" option is an alias for "--group=committer".

  - we keep an enum rather than a binary flag, to prepare
    for more values

  - we prefer switch statements to ternary assignment, since
    other group types will need more custom code

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2020-09-27 04:39:59 -04:00
committed by Junio C Hamano
parent 45d93eb824
commit 92338c450b
4 changed files with 65 additions and 12 deletions

View File

@@ -15,7 +15,11 @@ struct shortlog {
int in2;
int user_format;
int abbrev;
int committer;
enum {
SHORTLOG_GROUP_AUTHOR = 0,
SHORTLOG_GROUP_COMMITTER,
} group;
char *common_repo_prefix;
int email;