Skip to content

Commit c6b7206

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]>
1 parent 4e0df4e commit c6b7206

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

builtin/describe.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
#include "run-command.h"
1616
#include "revision.h"
1717
#include "list-objects.h"
18+
#include "commit-slab.h"
1819

1920
#define MAX_TAGS (FLAG_BITS - 1)
2021

22+
define_commit_slab(commit_names, struct commit_name *);
23+
2124
static const char * const describe_usage[] = {
2225
N_("git describe [<options>] [<commit-ish>...]"),
2326
N_("git describe [<options>] --dirty"),
@@ -37,6 +40,7 @@ static struct string_list patterns = STRING_LIST_INIT_NODUP;
3740
static struct string_list exclude_patterns = STRING_LIST_INIT_NODUP;
3841
static int always;
3942
static const char *suffix, *dirty, *broken;
43+
static struct commit_names commit_names;
4044

4145
/* diff-index command arguments to check if working tree is dirty. */
4246
static const char *diff_index_args[] = {
@@ -321,11 +325,14 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
321325
if (!have_util) {
322326
struct hashmap_iter iter;
323327
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);
325332
for (; n; n = hashmap_iter_next(&iter)) {
326333
c = lookup_commit_reference_gently(&n->peeled, 1);
327334
if (c)
328-
c->util = n;
335+
*commit_names_at(&commit_names, c) = n;
329336
}
330337
have_util = 1;
331338
}
@@ -336,8 +343,11 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
336343
while (list) {
337344
struct commit *c = pop_commit(&list);
338345
struct commit_list *parents = c->parents;
346+
struct commit_name **slot;
347+
339348
seen_commits++;
340-
n = c->util;
349+
slot = commit_names_peek(&commit_names, c);
350+
n = slot ? *slot : NULL;
341351
if (n) {
342352
if (!tags && !all && n->prio < 2) {
343353
unannotated_cnt++;

0 commit comments

Comments
 (0)