summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-09-27 08:40:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-27 19:21:05 (GMT)
commit63d24fa0b055d3f0386ee3686c07428450add708 (patch)
treeff5aae46b1399633020c6f584bdee8de5a6dc371 /Documentation
parent56d5dde7526e725a9e590f32fe38ce6b3391bc36 (diff)
downloadgit-63d24fa0b055d3f0386ee3686c07428450add708.zip
git-63d24fa0b055d3f0386ee3686c07428450add708.tar.gz
git-63d24fa0b055d3f0386ee3686c07428450add708.tar.bz2
shortlog: allow multiple groups to be specified
Now that shortlog supports reading from trailers, it can be useful to combine counts from multiple trailers, or between trailers and authors. This can be done manually by post-processing the output from multiple runs, but it's non-trivial to make sure that each name/commit pair is counted only once. This patch teaches shortlog to accept multiple --group options on the command line, and pull data from all of them. That makes it possible to run: git shortlog -ns --group=author --group=trailer:co-authored-by to get a shortlog that counts authors and co-authors equally. The implementation is mostly straightforward. The "group" enum becomes a bitfield, and the trailer key becomes a list. I didn't bother implementing the multi-group semantics for reading from stdin. It would be possible to do, but the existing matching code makes it awkward, and I doubt anybody cares. The duplicate suppression we used for trailers now covers authors and committers as well (though in non-trailer single-group mode we can skip the hash insertion and lookup, since we only see one value per commit). There is one subtlety: we now care about the case when no group bit is set (in which case we default to showing the author). The caller in builtin/log.c needs to be adapted to ask explicitly for authors, rather than relying on shortlog_init(). It would be possible with some gymnastics to make this keep working as-is, but it's not worth it for a single caller. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/git-shortlog.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index 3db0db2..fd93cd4 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -51,6 +51,7 @@ OPTIONS
Group commits based on `<type>`. If no `--group` option is
specified, the default is `author`. `<type>` is one of:
+
+--
- `author`, commits are grouped by author
- `committer`, commits are grouped by committer (the same as `-c`)
- `trailer:<field>`, the `<field>` is interpreted as a case-insensitive
@@ -68,6 +69,12 @@ Shortlog will attempt to parse each trailer value as a `name <email>`
identity. If successful, the mailmap is applied and the email is omitted
unless the `--email` option is specified. If the value cannot be parsed
as an identity, it will be taken literally and completely.
+--
++
+If `--group` is specified multiple times, commits are counted under each
+value (but again, only once per unique value in that commit). For
+example, `git shortlog --group=author --group=trailer:co-authored-by`
+counts both authors and co-authors.
-c::
--committer::