First, you can redirect the output of a command to a file:
for i in */.git; do
echo $i >> res;
cd $i/..;
git shortlog -sn --all --since=2.months.ago --author="First, Last"; >> res
done
Second, do that with Git 2.38 (Q3 2022), as before that, "git shortlog -n
"(man) relied on the underlying qsort()
to be stable, which shouldn't have.
Fixed.
See commit df534dc (14 Jul 2022) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit dd7c820, 22 Jul 2022)
shortlog
: use a stable sort
Signed-off-by: Johannes Schindelin
When sorting the output of git shortlog
(man) by count, a list of authors in alphabetical order is then sorted by contribution count.
Obviously, the idea is to maintain the alphabetical order for items with identical contribution count.
At the moment, this job is performed by qsort()
.
As that function is not guaranteed to implement a stable sort algorithm, this can lead to inconsistent and/or surprising behavior: items with identical contribution count could lose their alphabetical sub-order.
The qsort()
in MS Visual C's runtime does not implement a stable sort algorithm, and under certain circumstances, that leads to instances where two authors both are listed with 2 contributions, and are listed in inverse alphabetical order.
Let's instead use the stable sort provided by git_stable_qsort()
to avoid this inconsistency.
This is a companion to 2049b8d (diffcore_rename()
: use a stable sort, 2019-09-30, Git v2.24.0-rc0 -- merge listed in batch #7) (diffcore_rename()
: use a stable sort, 2019-09-30), mentioned here.