* How to determine the number of unique recent committers on a branch?
@ 2022-03-23 10:23 Sebastian Schuberth
2022-03-23 12:30 ` Ævar Arnfjörð Bjarmason
2022-03-23 20:48 ` Junio C Hamano
0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Schuberth @ 2022-03-23 10:23 UTC (permalink / raw)
To: Git Mailing List
Hi,
I'm trying to determine the number of unique committers who have
recently committed to a branch. "Recently" should be configurable, but
for my example I'll use a period of 3 months.
At first, I thought the [<refname>]@{<date>} syntax [1] in conjunction
with git "shortlog -s" could be helpful here, like
$ git shortlog -s main@{3.months.ago} | wc -l
But then I realized that just like with the --since option, the <date>
counts relative to the current date, not relative to the date of the
last commit on the given branch. To me, that's rather counterintuitive
for the [<refname>]@{<date>} syntax.
So, what would be a good way to achieve what I want with only
Git-means (and maybe `wc`), but without any awk / Perl scripting
magic?
Thanks in advance!
[1]: http://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to determine the number of unique recent committers on a branch?
2022-03-23 10:23 How to determine the number of unique recent committers on a branch? Sebastian Schuberth
@ 2022-03-23 12:30 ` Ævar Arnfjörð Bjarmason
2022-03-23 13:00 ` Sebastian Schuberth
2022-03-23 20:48 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-03-23 12:30 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: Git Mailing List
On Wed, Mar 23 2022, Sebastian Schuberth wrote:
> Hi,
>
> I'm trying to determine the number of unique committers who have
> recently committed to a branch. "Recently" should be configurable, but
> for my example I'll use a period of 3 months.
>
> At first, I thought the [<refname>]@{<date>} syntax [1] in conjunction
> with git "shortlog -s" could be helpful here, like
>
> $ git shortlog -s main@{3.months.ago} | wc -l
>
> But then I realized that just like with the --since option, the <date>
> counts relative to the current date, not relative to the date of the
> last commit on the given branch. To me, that's rather counterintuitive
> for the [<refname>]@{<date>} syntax.
>
> So, what would be a good way to achieve what I want with only
> Git-means (and maybe `wc`), but without any awk / Perl scripting
> magic?
>
> Thanks in advance!
>
> [1]: http://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem
The ref@{} syntax will give you ref*log* times, which is probably not
what you want.
I think --since to "rev-list" combined with e.g. "shortlog" is what you
want here, e.g. on git.git:
$ git -P shortlog --since=2.weeks.ago -sn origin/master
36 Junio C Hamano
12 Derrick Stolee
2 Shubham Mishra
1 Michael J Gruber
1 Ævar Arnfjörð Bjarmason
Maybe there's a way to get it to spew that out without the numeric
summary, but I can't recall one offhand. I.e. you'd still need awk/cut,
but at least not uniq anymore..
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to determine the number of unique recent committers on a branch?
2022-03-23 12:30 ` Ævar Arnfjörð Bjarmason
@ 2022-03-23 13:00 ` Sebastian Schuberth
2022-03-23 14:47 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Schuberth @ 2022-03-23 13:00 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Git Mailing List
On Wed, Mar 23, 2022 at 1:33 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> I think --since to "rev-list" combined with e.g. "shortlog" is what you
> want here, e.g. on git.git:
>
> $ git -P shortlog --since=2.weeks.ago -sn origin/master
But that still interprets "2.weeks.ago" relative to today, right? So,
for a repo to which no one committed to in the last 2 weeks, it would
show nothing. But what I'd like to get is the number of committers
since 2 weeks before the latest commit. Any idea how to get that
easily?
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to determine the number of unique recent committers on a branch?
2022-03-23 13:00 ` Sebastian Schuberth
@ 2022-03-23 14:47 ` Ævar Arnfjörð Bjarmason
2022-03-23 22:14 ` Sebastian Schuberth
0 siblings, 1 reply; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-03-23 14:47 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: Git Mailing List
On Wed, Mar 23 2022, Sebastian Schuberth wrote:
> On Wed, Mar 23, 2022 at 1:33 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>
>> I think --since to "rev-list" combined with e.g. "shortlog" is what you
>> want here, e.g. on git.git:
>>
>> $ git -P shortlog --since=2.weeks.ago -sn origin/master
>
> But that still interprets "2.weeks.ago" relative to today, right? So,
> for a repo to which no one committed to in the last 2 weeks, it would
> show nothing. But what I'd like to get is the number of committers
> since 2 weeks before the latest commit. Any idea how to get that
> easily?
Ah, sorry. I managed to (mis)read your question.
Perhaps there's a way to do that in one command, but I don't think so,
but I may be wrong.
But you *can* do by grabbing the epoch from the tip commit and doing
some basic shell-math on it:
git log --since=$(($(git log --oneline -1 --date=unix --pretty=format:%ad origin/master) - $((60*60*24*7*2)) )) origin/master
It would be nice if we had some option to to do that, e.g.:
git log --since=2.weeks.ago --date-now=February.2018
Or To get you things in late January 2018. Or even:
git -c core.time="February.2018" log --since=2.weeks.ago
To fool the entirety of git to use a given time() as current (but of
course it would also need to "adjust back" commit dates for relative
--since).
I'm 99% sure we don't have that, especially from looking at some of the
code just now. But in the meantime you can hack it as above.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to determine the number of unique recent committers on a branch?
2022-03-23 10:23 How to determine the number of unique recent committers on a branch? Sebastian Schuberth
2022-03-23 12:30 ` Ævar Arnfjörð Bjarmason
@ 2022-03-23 20:48 ` Junio C Hamano
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2022-03-23 20:48 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: Git Mailing List
Sebastian Schuberth <sschuberth@gmail.com> writes:
> I'm trying to determine the number of unique committers who have
> recently committed to a branch. "Recently" should be configurable, but
> for my example I'll use a period of 3 months.
>
> At first, I thought the [<refname>]@{<date>} syntax [1] in conjunction
> with git "shortlog -s" could be helpful here, like
>
> $ git shortlog -s main@{3.months.ago} | wc -l
As reflog is pretty much the local matter, this is "find out the
commit _I_ happened to have seen at the tip of 'main' in _this_
repository 3 months ago, and count all commits before that one".
If you were taking 6 months sabbatical, not fetching the repository
during that time, and then you fetched to become up to date with the
upstream, you may have had a copy of the shared project history only
as of 6 months ago with that notation, even though the syntax is
asking for "3 months ago", simply because that was the commit your
repository had 3 months ago at the tip of the branch.
$ git log --until=3.months.ago
would instead look at the timestamp recorded in commit objects,
which would probably be more relevant to project participants.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to determine the number of unique recent committers on a branch?
2022-03-23 14:47 ` Ævar Arnfjörð Bjarmason
@ 2022-03-23 22:14 ` Sebastian Schuberth
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Schuberth @ 2022-03-23 22:14 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Git Mailing List
On Wed, Mar 23, 2022 at 3:57 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> But you *can* do by grabbing the epoch from the tip commit and doing
> some basic shell-math on it:
>
> git log --since=$(($(git log --oneline -1 --date=unix --pretty=format:%ad origin/master) - $((60*60*24*7*2)) )) origin/master
Thanks, that works!
However, as --since works on the commit date, shouldn't it also be %cd
instead of %ad in the format string for consistency?
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-23 22:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 10:23 How to determine the number of unique recent committers on a branch? Sebastian Schuberth
2022-03-23 12:30 ` Ævar Arnfjörð Bjarmason
2022-03-23 13:00 ` Sebastian Schuberth
2022-03-23 14:47 ` Ævar Arnfjörð Bjarmason
2022-03-23 22:14 ` Sebastian Schuberth
2022-03-23 20:48 ` Junio C Hamano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.