6
6
#include "refs.h"
7
7
#include "parse-options.h"
8
8
#include "sha1-lookup.h"
9
+ #include "commit-slab.h"
9
10
10
11
#define CUTOFF_DATE_SLOP 86400 /* one day */
11
12
@@ -17,11 +18,26 @@ typedef struct rev_name {
17
18
int from_tag ;
18
19
} rev_name ;
19
20
21
+ define_commit_slab (commit_rev_name , struct rev_name * );
22
+
20
23
static timestamp_t cutoff = TIME_MAX ;
24
+ static struct commit_rev_name rev_names ;
21
25
22
26
/* How many generations are maximally preferred over _one_ merge traversal? */
23
27
#define MERGE_TRAVERSAL_WEIGHT 65535
24
28
29
+ static struct rev_name * get_commit_rev_name (struct commit * commit )
30
+ {
31
+ struct rev_name * * slot = commit_rev_name_peek (& rev_names , commit );
32
+
33
+ return slot ? * slot : NULL ;
34
+ }
35
+
36
+ static void set_commit_rev_name (struct commit * commit , struct rev_name * name )
37
+ {
38
+ * commit_rev_name_at (& rev_names , commit ) = name ;
39
+ }
40
+
25
41
static int is_better_name (struct rev_name * name ,
26
42
const char * tip_name ,
27
43
timestamp_t taggerdate ,
@@ -65,7 +81,7 @@ static void name_rev(struct commit *commit,
65
81
int generation , int distance , int from_tag ,
66
82
int deref )
67
83
{
68
- struct rev_name * name = ( struct rev_name * ) commit -> util ;
84
+ struct rev_name * name = get_commit_rev_name ( commit ) ;
69
85
struct commit_list * parents ;
70
86
int parent_number = 1 ;
71
87
char * to_free = NULL ;
@@ -84,7 +100,7 @@ static void name_rev(struct commit *commit,
84
100
85
101
if (name == NULL ) {
86
102
name = xmalloc (sizeof (rev_name ));
87
- commit -> util = name ;
103
+ set_commit_rev_name ( commit , name ) ;
88
104
goto copy_data ;
89
105
} else if (is_better_name (name , tip_name , taggerdate ,
90
106
generation , distance , from_tag )) {
@@ -296,7 +312,7 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf)
296
312
if (o -> type != OBJ_COMMIT )
297
313
return get_exact_ref_match (o );
298
314
c = (struct commit * ) o ;
299
- n = c -> util ;
315
+ n = get_commit_rev_name ( c ) ;
300
316
if (!n )
301
317
return NULL ;
302
318
@@ -413,6 +429,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
413
429
OPT_END (),
414
430
};
415
431
432
+ init_commit_rev_name (& rev_names );
416
433
git_config (git_default_config , NULL );
417
434
argc = parse_options (argc , argv , prefix , opts , name_rev_usage , 0 );
418
435
if (all + transform_stdin + !!argc > 1 ) {
0 commit comments