describe: use commit-slab for commit names instead of commit->util
It's done so that commit->util can be removed. See more explanation in the commit that removes commit->util. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 19, 2018 at 07:28 UTC
c6b7206b0d532d2d1eb4518d2d680b7f3ce105cd
1 file changed
+13
-3
builtin/describe.c
+13
-3
@@ -15,9 +15,12 @@
15
#include "run-command.h"
16
#include "revision.h"
17
#include "list-objects.h"
18
+#include "commit-slab.h"
19
20
#define MAX_TAGS (FLAG_BITS - 1)
21
22
+define_commit_slab(commit_names, struct commit_name *);
23
+
24
static const char * const describe_usage[] = {
25
N_("git describe [<options>] [<commit-ish>...]"),
26
N_("git describe [<options>] --dirty"),
@@ -37,6 +40,7 @@ static struct string_list patterns = STRING_LIST_INIT_NODUP;
40
static struct string_list exclude_patterns = STRING_LIST_INIT_NODUP;
41
static int always;
42
static const char *suffix, *dirty, *broken;
43
+static struct commit_names commit_names;
44
45
/* diff-index command arguments to check if working tree is dirty. */
46
static const char *diff_index_args[] = {
@@ -321,11 +325,14 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
325
if (!have_util) {
326
struct hashmap_iter iter;
327
struct commit *c;
324
- struct commit_name *n = hashmap_iter_first(&names, &iter);
328
+ struct commit_name *n;
329
+
330
+ init_commit_names(&commit_names);
331
+ n = hashmap_iter_first(&names, &iter);
332
for (; n; n = hashmap_iter_next(&iter)) {
333
c = lookup_commit_reference_gently(&n->peeled, 1);
334
if (c)
328
- c->util = n;
335
+ *commit_names_at(&commit_names, c) = n;
336
}
337
have_util = 1;
338
}
@@ -336,8 +343,11 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
343
while (list) {
344
struct commit *c = pop_commit(&list);
345
struct commit_list *parents = c->parents;
346
+ struct commit_name **slot;
347
+
348
seen_commits++;
340
- n = c->util;
349
+ slot = commit_names_peek(&commit_names, c);
350
+ n = slot ? *slot : NULL;
351
if (n) {
352
if (!tags && !all && n->prio < 2) {
353
unannotated_cnt++;