git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git shortlog -sn --follow -- <path>" counts all commits to entire repo

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 8, 2017, 06:38 UTC
Message-ID
<xmqqo9qlzodi.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170908051015.ybq4egdrddecl4se@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> That's definitely the intent, but I think --follow is just buggy here.
> We don't seem to trigger a diff, which is where "git log" does the
> follow check (because of the way it's bolted onto the diff, and not the
> actual pathspec-pruning mechanism).

Yeah, at the same time, the usual caveat about "--follow" that it would not work in general in a history with forks and merges due to its keeping track of a single pathspec that is globally swapped out.

Show 7 quoted lines
> Something like the patch below seems to work, but there are a lot of
> open questions. And it would probably want to do something to prevent
> nonsense like "shortlog -p" from showing actual diffs.
>
> I suspect a better solution might involve actually building on
> log-tree.c to do the traversal (since this internal traversal is
> supposed to be equivalent to "git log | git shortlog").

Probably. That approach would also have an added benefit that when "--follow" is fixed to keep track of which path it is following per traversal for "git log", the result from "git shortlog --follow" would automatically become correct, I guess?

Thanks.
Previous: Jeff KingNext: Jeff King
Message 4 of 8 in “"git shortlog -sn --follow -- <path>" counts all commits to entire repo”
  1. ВалентинSep 7, 2017
  2. Stefan BellerSep 7, 2017
  3. Jeff KingSep 8, 2017
  4. Junio C HamanoSep 8, 2017
  5. Jeff KingSep 8, 2017
  6. Junio C HamanoSep 8, 2017
  7. Jeff KingSep 9, 2017
  8. Junio C HamanoSep 10, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.