Message ID | pull.1290.git.1657813429221.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | df534dcbaafa74be9e922418712bede75676588b |
Headers | show |
Series | shortlog: use a stable sort | expand |
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > When sorting the output of `git shortlog` 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. > ... > if (log->sort_by_number) > - QSORT(log->list.items, log->list.nr, > + STABLE_QSORT(log->list.items, log->list.nr, Makes perfect sense. Will queue. Thanks.
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > why does our current CI not fail in the vs-test job?". The answer is > surprisingly trivial: Because our CMake-based definition universally > defines INTERNAL_QSORT > [https://github.com/git/git/blob/v2.37.1/contrib/buildsystems/CMakeLists.txt#L227], > which should actually not even be necessary, while the Azure Pipeline I > used still calls make vcxproj to generate the Visual Studio build > definition and does not define that flag. Diversity in test environments is very good.
diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 35825f075e3..086dfee45aa 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -443,7 +443,7 @@ void shortlog_output(struct shortlog *log) struct strbuf sb = STRBUF_INIT; if (log->sort_by_number) - QSORT(log->list.items, log->list.nr, + STABLE_QSORT(log->list.items, log->list.nr, log->summary ? compare_by_counter : compare_by_list); for (i = 0; i < log->list.nr; i++) { const struct string_list_item *item = &log->list.items[i];