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>
5 files changed
tree: ff5aae46b1399633020c6f584bdee8de5a6dc371
  1. .cirrus.yml
  2. .clang-format
  3. .editorconfig
  4. .gitattributes
  5. .github/
  6. .gitignore
  7. .gitmodules
  8. .mailmap
  9. .travis.yml
  10. .tsan-suppressions
  11. CODE_OF_CONDUCT.md
  12. COPYING
  13. Documentation/
  14. GIT-VERSION-GEN
  15. INSTALL
  16. LGPL-2.1
  17. Makefile
  18. README.md
  19. abspath.c
  20. aclocal.m4
  21. add-interactive.c
  22. add-interactive.h
  23. add-patch.c
  24. advice.c
  25. advice.h
  26. alias.c
  27. alias.h
  28. alloc.c
  29. alloc.h
  30. apply.c
  31. apply.h
  32. archive-tar.c
  33. archive-zip.c
  34. archive.c
  35. archive.h
  36. argv-array.c
  37. argv-array.h
  38. attr.c
  39. attr.h
  40. banned.h
  41. base85.c
  42. bisect.c
  43. bisect.h
  44. blame.c
  45. blame.h
  46. blob.c
  47. blob.h
  48. block-sha1/
  49. bloom.c
  50. bloom.h
  51. branch.c
  52. branch.h
  53. bugreport.c
  54. builtin.h
  55. builtin/
  56. bulk-checkin.c
  57. bulk-checkin.h
  58. bundle.c
  59. bundle.h
  60. cache-tree.c
  61. cache-tree.h
  62. cache.h
  63. chdir-notify.c
  64. chdir-notify.h
  65. check-builtins.sh
  66. check_bindir
  67. checkout.c
  68. checkout.h
  69. ci/
  70. color.c
  71. color.h
  72. column.c
  73. column.h
  74. combine-diff.c
  75. command-list.txt
  76. commit-graph.c
  77. commit-graph.h
  78. commit-reach.c
  79. commit-reach.h
  80. commit-slab-decl.h
  81. commit-slab-impl.h
  82. commit-slab.h
  83. commit.c
  84. commit.h
  85. common-main.c
  86. compat/
  87. config.c
  88. config.h
  89. config.mak.dev
  90. config.mak.in
  91. config.mak.uname
  92. configure.ac
  93. connect.c
  94. connect.h
  95. connected.c
  96. connected.h
  97. contrib/
  98. convert.c
  99. convert.h
  100. copy.c
  101. credential-cache--daemon.c
  102. credential-cache.c
  103. credential-store.c
  104. credential.c
  105. credential.h
  106. csum-file.c
  107. csum-file.h
  108. ctype.c
  109. daemon.c
  110. date.c
  111. decorate.c
  112. decorate.h
  113. delta-islands.c
  114. delta-islands.h
  115. delta.h
  116. detect-compiler
  117. diff-delta.c
  118. diff-lib.c
  119. diff-no-index.c
  120. diff.c
  121. diff.h
  122. diffcore-break.c
  123. diffcore-delta.c
  124. diffcore-order.c
  125. diffcore-pickaxe.c
  126. diffcore-rename.c
  127. diffcore.h
  128. dir-iterator.c
  129. dir-iterator.h
  130. dir.c
  131. dir.h
  132. editor.c
  133. entry.c
  134. environment.c
  135. ewah/
  136. exec-cmd.c
  137. exec-cmd.h
  138. fast-import.c
  139. fetch-negotiator.c
  140. fetch-negotiator.h
  141. fetch-pack.c
  142. fetch-pack.h
  143. fmt-merge-msg.c
  144. fmt-merge-msg.h
  145. fsck.c
  146. fsck.h
  147. fsmonitor.c
  148. fsmonitor.h
  149. fuzz-commit-graph.c
  150. fuzz-pack-headers.c
  151. fuzz-pack-idx.c
  152. generate-cmdlist.sh
  153. generate-configlist.sh
  154. gettext.c
  155. gettext.h
  156. git-add--interactive.perl
  157. git-archimport.perl
  158. git-bisect.sh
  159. git-compat-util.h
  160. git-cvsexportcommit.perl
  161. git-cvsimport.perl
  162. git-cvsserver.perl
  163. git-difftool--helper.sh
  164. git-filter-branch.sh
  165. git-gui/
  166. git-instaweb.sh
  167. git-merge-octopus.sh
  168. git-merge-one-file.sh
  169. git-merge-resolve.sh
  170. git-mergetool--lib.sh
  171. git-mergetool.sh
  172. git-p4.py
  173. git-parse-remote.sh
  174. git-quiltimport.sh
  175. git-rebase--preserve-merges.sh
  176. git-request-pull.sh
  177. git-send-email.perl
  178. git-sh-i18n.sh
  179. git-sh-setup.sh
  180. git-submodule.sh
  181. git-svn.perl
  182. git-web--browse.sh
  183. git.c
  184. git.rc
  185. gitk-git/
  186. gitweb/
  187. gpg-interface.c
  188. gpg-interface.h
  189. graph.c
  190. graph.h
  191. grep.c
  192. grep.h
  193. hash.h
  194. hashmap.c
  195. hashmap.h
  196. help.c
  197. help.h
  198. hex.c
  199. http-backend.c
  200. http-fetch.c
  201. http-push.c
  202. http-walker.c
  203. http.c
  204. http.h
  205. ident.c
  206. imap-send.c
  207. interdiff.c
  208. interdiff.h
  209. iterator.h
  210. json-writer.c
  211. json-writer.h
  212. khash.h
  213. kwset.c
  214. kwset.h
  215. levenshtein.c
  216. levenshtein.h
  217. line-log.c
  218. line-log.h
  219. line-range.c
  220. line-range.h
  221. linear-assignment.c
  222. linear-assignment.h
  223. list-objects-filter-options.c
  224. list-objects-filter-options.h
  225. list-objects-filter.c
  226. list-objects-filter.h
  227. list-objects.c
  228. list-objects.h
  229. list.h
  230. ll-merge.c
  231. ll-merge.h
  232. lockfile.c
  233. lockfile.h
  234. log-tree.c
  235. log-tree.h
  236. ls-refs.c
  237. ls-refs.h
  238. mailinfo.c
  239. mailinfo.h
  240. mailmap.c
  241. mailmap.h
  242. match-trees.c
  243. mem-pool.c
  244. mem-pool.h
  245. merge-blobs.c
  246. merge-blobs.h
  247. merge-recursive.c
  248. merge-recursive.h
  249. merge.c
  250. mergesort.c
  251. mergesort.h
  252. mergetools/
  253. midx.c
  254. midx.h
  255. name-hash.c
  256. negotiator/
  257. notes-cache.c
  258. notes-cache.h
  259. notes-merge.c
  260. notes-merge.h
  261. notes-utils.c
  262. notes-utils.h
  263. notes.c
  264. notes.h
  265. object-store.h
  266. object.c
  267. object.h
  268. oid-array.c
  269. oid-array.h
  270. oidmap.c
  271. oidmap.h
  272. oidset.c
  273. oidset.h
  274. pack-bitmap-write.c
  275. pack-bitmap.c
  276. pack-bitmap.h
  277. pack-check.c
  278. pack-objects.c
  279. pack-objects.h
  280. pack-revindex.c
  281. pack-revindex.h
  282. pack-write.c
  283. pack.h
  284. packfile.c
  285. packfile.h
  286. pager.c
  287. parse-options-cb.c
  288. parse-options.c
  289. parse-options.h
  290. patch-delta.c
  291. patch-ids.c
  292. patch-ids.h
  293. path.c
  294. path.h
  295. pathspec.c
  296. pathspec.h
  297. perl/
  298. pkt-line.c
  299. pkt-line.h
  300. po/
  301. ppc/
  302. preload-index.c
  303. pretty.c
  304. pretty.h
  305. prio-queue.c
  306. prio-queue.h
  307. progress.c
  308. progress.h
  309. promisor-remote.c
  310. promisor-remote.h
  311. prompt.c
  312. prompt.h
  313. protocol.c
  314. protocol.h
  315. prune-packed.c
  316. prune-packed.h
  317. quote.c
  318. quote.h
  319. range-diff.c
  320. range-diff.h
  321. reachable.c
  322. reachable.h
  323. read-cache.c
  324. rebase-interactive.c
  325. rebase-interactive.h
  326. rebase.c
  327. rebase.h
  328. ref-filter.c
  329. ref-filter.h
  330. reflog-walk.c
  331. reflog-walk.h
  332. refs.c
  333. refs.h
  334. refs/
  335. refspec.c
  336. refspec.h
  337. remote-curl.c
  338. remote-testsvn.c
  339. remote.c
  340. remote.h
  341. replace-object.c
  342. replace-object.h
  343. repo-settings.c
  344. repository.c
  345. repository.h
  346. rerere.c
  347. rerere.h
  348. reset.c
  349. reset.h
  350. resolve-undo.c
  351. resolve-undo.h
  352. revision.c
  353. revision.h
  354. run-command.c
  355. run-command.h
  356. send-pack.c
  357. send-pack.h
  358. sequencer.c
  359. sequencer.h
  360. serve.c
  361. serve.h
  362. server-info.c
  363. setup.c
  364. sh-i18n--envsubst.c
  365. sha1-file.c
  366. sha1-lookup.c
  367. sha1-lookup.h
  368. sha1-name.c
  369. sha1dc/
  370. sha1dc_git.c
  371. sha1dc_git.h
  372. sha256/
  373. shallow.c
  374. shallow.h
  375. shell.c
  376. shortlog.h
  377. sideband.c
  378. sideband.h
  379. sigchain.c
  380. sigchain.h
  381. split-index.c
  382. split-index.h
  383. stable-qsort.c
  384. strbuf.c
  385. strbuf.h
  386. streaming.c
  387. streaming.h
  388. string-list.c
  389. string-list.h
  390. sub-process.c
  391. sub-process.h
  392. submodule-config.c
  393. submodule-config.h
  394. submodule.c
  395. submodule.h
  396. symlinks.c
  397. t/
  398. tag.c
  399. tag.h
  400. tar.h
  401. tempfile.c
  402. tempfile.h
  403. templates/
  404. thread-utils.c
  405. thread-utils.h
  406. tmp-objdir.c
  407. tmp-objdir.h
  408. trace.c
  409. trace.h
  410. trace2.c
  411. trace2.h
  412. trace2/
  413. trailer.c
  414. trailer.h
  415. transport-helper.c
  416. transport-internal.h
  417. transport.c
  418. transport.h
  419. tree-diff.c
  420. tree-walk.c
  421. tree-walk.h
  422. tree.c
  423. tree.h
  424. unicode-width.h
  425. unimplemented.sh
  426. unix-socket.c
  427. unix-socket.h
  428. unpack-trees.c
  429. unpack-trees.h
  430. upload-pack.c
  431. upload-pack.h
  432. url.c
  433. url.h
  434. urlmatch.c
  435. urlmatch.h
  436. usage.c
  437. userdiff.c
  438. userdiff.h
  439. utf8.c
  440. utf8.h
  441. varint.c
  442. varint.h
  443. vcs-svn/
  444. version.c
  445. version.h
  446. versioncmp.c
  447. walker.c
  448. walker.h
  449. wildmatch.c
  450. wildmatch.h
  451. worktree.c
  452. worktree.h
  453. wrap-for-bin.sh
  454. wrapper.c
  455. write-or-die.c
  456. ws.c
  457. wt-status.c
  458. wt-status.h
  459. xdiff-interface.c
  460. xdiff-interface.h
  461. xdiff/
  462. zlib.c
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks