{"thread":{"id":"57602","subject":"How to determine the number of unique recent committers on a branch?","startedAt":"2022-03-23T10:23:25Z","lastAt":"2022-03-23T22:14:44Z","messageCount":6,"participants":["Sebastian Schuberth","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"451971","messageId":"CAHGBnuPavzr_gq0ake6bOQETmHBnU2XOWdDz-UtkBP_+rRdYfA@mail.gmail.com","threadId":"57602","inReplyTo":null,"subject":"How to determine the number of unique recent committers on a branch?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2022-03-23T10:23:07Z","receivedAt":"2022-03-23T10:23:25Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"Hi,\n\nI'm trying to determine the number of unique committers who have\nrecently committed to a branch. \"Recently\" should be configurable, but\nfor my example I'll use a period of 3 months.\n\nAt first, I thought the [<refname>]@{<date>} syntax [1] in conjunction\nwith git \"shortlog -s\" could be helpful here, like\n\n$ git shortlog -s main@{3.months.ago} | wc -l\n\nBut then I realized that just like with the --since option, the <date>\ncounts relative to the current date, not relative to the date of the\nlast commit on the given branch. To me, that's rather counterintuitive\nfor the [<refname>]@{<date>} syntax.\n\nSo, what would be a good way to achieve what I want with only\nGit-means (and maybe `wc`), but without any awk / Perl scripting\nmagic?\n\nThanks in advance!\n\n[1]: http://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem\n\n-- \nSebastian Schuberth\n"},{"id":"451974","messageId":"220323.86o81wonlf.gmgdl@evledraar.gmail.com","threadId":"57602","inReplyTo":"CAHGBnuPavzr_gq0ake6bOQETmHBnU2XOWdDz-UtkBP_+rRdYfA@mail.gmail.com","subject":"Re: How to determine the number of unique recent committers on a branch?","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-23T12:30:50Z","receivedAt":"2022-03-23T12:33:24Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Mar 23 2022, Sebastian Schuberth wrote:\n\n> Hi,\n>\n> I'm trying to determine the number of unique committers who have\n> recently committed to a branch. \"Recently\" should be configurable, but\n> for my example I'll use a period of 3 months.\n>\n> At first, I thought the [<refname>]@{<date>} syntax [1] in conjunction\n> with git \"shortlog -s\" could be helpful here, like\n>\n> $ git shortlog -s main@{3.months.ago} | wc -l\n>\n> But then I realized that just like with the --since option, the <date>\n> counts relative to the current date, not relative to the date of the\n> last commit on the given branch. To me, that's rather counterintuitive\n> for the [<refname>]@{<date>} syntax.\n>\n> So, what would be a good way to achieve what I want with only\n> Git-means (and maybe `wc`), but without any awk / Perl scripting\n> magic?\n>\n> Thanks in advance!\n>\n> [1]: http://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem\n\nThe ref@{} syntax will give you ref*log* times, which is probably not\nwhat you want.\n\nI think --since to \"rev-list\" combined with e.g. \"shortlog\" is what you\nwant here, e.g. on git.git:\n\t\n\t$ git -P shortlog --since=2.weeks.ago -sn origin/master \n\t    36  Junio C Hamano\n\t    12  Derrick Stolee\n\t     2  Shubham Mishra\n\t     1  Michael J Gruber\n\t     1  Ævar Arnfjörð Bjarmason\n\nMaybe there's a way to get it to spew that out without the numeric\nsummary, but I can't recall one offhand. I.e. you'd still need awk/cut,\nbut at least not uniq anymore..\n"},{"id":"451976","messageId":"CAHGBnuMRKhsF-xCL944KD5GFPWYe-9cSp6FBZfaZ7bdVTkgjng@mail.gmail.com","threadId":"57602","inReplyTo":"220323.86o81wonlf.gmgdl@evledraar.gmail.com","subject":"Re: How to determine the number of unique recent committers on a branch?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2022-03-23T13:00:31Z","receivedAt":"2022-03-23T13:00:50Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Wed, Mar 23, 2022 at 1:33 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n\n> I think --since to \"rev-list\" combined with e.g. \"shortlog\" is what you\n> want here, e.g. on git.git:\n>\n>         $ git -P shortlog --since=2.weeks.ago -sn origin/master\n\nBut that still interprets \"2.weeks.ago\" relative to today, right? So,\nfor a repo to which no one committed to in the last 2 weeks, it would\nshow nothing. But what I'd like to get is the number of committers\nsince 2 weeks before the latest commit. Any idea how to get that\neasily?\n\n-- \nSebastian Schuberth\n"},{"id":"451995","messageId":"220323.86bkxwogxs.gmgdl@evledraar.gmail.com","threadId":"57602","inReplyTo":"CAHGBnuMRKhsF-xCL944KD5GFPWYe-9cSp6FBZfaZ7bdVTkgjng@mail.gmail.com","subject":"Re: How to determine the number of unique recent committers on a branch?","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-23T14:47:42Z","receivedAt":"2022-03-23T14:57:10Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Mar 23 2022, Sebastian Schuberth wrote:\n\n> On Wed, Mar 23, 2022 at 1:33 PM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>\n>> I think --since to \"rev-list\" combined with e.g. \"shortlog\" is what you\n>> want here, e.g. on git.git:\n>>\n>>         $ git -P shortlog --since=2.weeks.ago -sn origin/master\n>\n> But that still interprets \"2.weeks.ago\" relative to today, right? So,\n> for a repo to which no one committed to in the last 2 weeks, it would\n> show nothing. But what I'd like to get is the number of committers\n> since 2 weeks before the latest commit. Any idea how to get that\n> easily?\n\nAh, sorry. I managed to (mis)read your question.\n\nPerhaps there's a way to do that in one command, but I don't think so,\nbut I may be wrong.\n\nBut you *can* do by grabbing the epoch from the tip commit and doing\nsome basic shell-math on it:\n\n    git log --since=$(($(git log --oneline -1 --date=unix --pretty=format:%ad origin/master) - $((60*60*24*7*2)) )) origin/master\n\nIt would be nice if we had some option to to do that, e.g.:\n\n    git log --since=2.weeks.ago --date-now=February.2018\n\nOr To get you things in late January 2018. Or even:\n\n    git -c core.time=\"February.2018\" log --since=2.weeks.ago\n\nTo fool the entirety of git to use a given time() as current (but of\ncourse it would also need to \"adjust back\" commit dates for relative\n--since).\n\nI'm 99% sure we don't have that, especially from looking at some of the\ncode just now. But in the meantime you can hack it as above.\n"},{"id":"452061","messageId":"xmqqy210qttf.fsf@gitster.g","threadId":"57602","inReplyTo":"CAHGBnuPavzr_gq0ake6bOQETmHBnU2XOWdDz-UtkBP_+rRdYfA@mail.gmail.com","subject":"Re: How to determine the number of unique recent committers on a branch?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-23T20:48:12Z","receivedAt":"2022-03-23T20:48:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sebastian Schuberth <sschuberth@gmail.com> writes:\n\n> I'm trying to determine the number of unique committers who have\n> recently committed to a branch. \"Recently\" should be configurable, but\n> for my example I'll use a period of 3 months.\n>\n> At first, I thought the [<refname>]@{<date>} syntax [1] in conjunction\n> with git \"shortlog -s\" could be helpful here, like\n>\n> $ git shortlog -s main@{3.months.ago} | wc -l\n\nAs reflog is pretty much the local matter, this is \"find out the\ncommit _I_ happened to have seen at the tip of 'main' in _this_\nrepository 3 months ago, and count all commits before that one\".\n\nIf you were taking 6 months sabbatical, not fetching the repository\nduring that time, and then you fetched to become up to date with the\nupstream, you may have had a copy of the shared project history only\nas of 6 months ago with that notation, even though the syntax is\nasking for \"3 months ago\", simply because that was the commit your\nrepository had 3 months ago at the tip of the branch.\n\n    $ git log --until=3.months.ago\n\nwould instead look at the timestamp recorded in commit objects,\nwhich would probably be more relevant to project participants.\n"},{"id":"452077","messageId":"CAHGBnuMjRNiHr+V7Vc6N72CFbtVDmTapf3w1vn=1TOPB89W0ag@mail.gmail.com","threadId":"57602","inReplyTo":"220323.86bkxwogxs.gmgdl@evledraar.gmail.com","subject":"Re: How to determine the number of unique recent committers on a branch?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2022-03-23T22:14:23Z","receivedAt":"2022-03-23T22:14:44Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Wed, Mar 23, 2022 at 3:57 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n\n> But you *can* do by grabbing the epoch from the tip commit and doing\n> some basic shell-math on it:\n>\n>     git log --since=$(($(git log --oneline -1 --date=unix --pretty=format:%ad origin/master) - $((60*60*24*7*2)) )) origin/master\n\nThanks, that works!\n\nHowever, as --since works on the commit date, shouldn't it also be %cd\ninstead of %ad in the format string for consistency?\n\n-- \nSebastian Schuberth\n"}]}