70
commit_pos_at(&commit_pos, b);
71
}
72
73
+static int commit_gen_cmp(const void *va, const void *vb)
74
+{
75
+ const struct commit *a = *(const struct commit **)va;
76
+ const struct commit *b = *(const struct commit **)vb;
77
+
78
+ /* lower generation commits first */
79
+ if (a->generation < b->generation)
80
+ return -1;
81
+ else if (a->generation > b->generation)
82
+ return 1;
83
+
84
+ /* use date as a heuristic when generations are equal */
85
+ if (a->date < b->date)
86
+ return -1;
87
+ else if (a->date > b->date)
88
+ return 1;
89
+ return 0;
90
+}
91
+
92
char *get_commit_graph_filename(struct object_directory *obj_dir)
93
{
94
return xstrfmt("%s/info/commit-graph", obj_dir->path);
834
report_progress:1,
835
split:1,
836
check_oids:1,
818
- changed_paths:1;
837
+ changed_paths:1,
838
+ order_by_pack:1;
839
840
const struct split_commit_graph_opts *split_opts;
841
size_t total_bloom_filter_data_size;
1198
1199
ALLOC_ARRAY(sorted_commits, ctx->commits.nr);
1200
COPY_ARRAY(sorted_commits, ctx->commits.list, ctx->commits.nr);
1181
- QSORT(sorted_commits, ctx->commits.nr, commit_pos_cmp);
1201
+
1202
+ if (ctx->order_by_pack)
1203
+ QSORT(sorted_commits, ctx->commits.nr, commit_pos_cmp);
1204
+ else
1205
+ QSORT(sorted_commits, ctx->commits.nr, commit_gen_cmp);
1206
1207
for (i = 0; i < ctx->commits.nr; i++) {
1208
struct commit *c = sorted_commits[i];
1908
}
1909
1910
if (pack_indexes) {
1911
+ ctx->order_by_pack = 1;
1912
if ((res = fill_oids_from_packs(ctx, pack_indexes)))
1913
goto cleanup;
1914
}
1918
goto cleanup;
1919
}
1920
1896
- if (!pack_indexes && !commit_hex)
1921
+ if (!pack_indexes && !commit_hex) {
1922
+ ctx->order_by_pack = 1;
1923
fill_oids_from_all_packs(ctx);
1924
+ }
1925
1926
close_reachable(ctx);
1927