#include "refs.h"
#include "parse-options.h"
#include "sha1-lookup.h"
+#include "commit-slab.h"
#define CUTOFF_DATE_SLOP 86400 /* one day */
int from_tag;
} rev_name;
+define_commit_slab(commit_rev_name, struct rev_name *);
+
static timestamp_t cutoff = TIME_MAX;
+static struct commit_rev_name rev_names;
/* How many generations are maximally preferred over _one_ merge traversal? */
#define MERGE_TRAVERSAL_WEIGHT 65535
+static struct rev_name *get_commit_rev_name(struct commit *commit)
+{
+ struct rev_name **slot = commit_rev_name_peek(&rev_names, commit);
+
+ return slot ? *slot : NULL;
+}
+
+static void set_commit_rev_name(struct commit *commit, struct rev_name *name)
+{
+ *commit_rev_name_at(&rev_names, commit) = name;
+}
+
static int is_better_name(struct rev_name *name,
const char *tip_name,
timestamp_t taggerdate,
int generation, int distance, int from_tag,
int deref)
{
- struct rev_name *name = (struct rev_name *)commit->util;
+ struct rev_name *name = get_commit_rev_name(commit);
struct commit_list *parents;
int parent_number = 1;
char *to_free = NULL;
if (name == NULL) {
name = xmalloc(sizeof(rev_name));
- commit->util = name;
+ set_commit_rev_name(commit, name);
goto copy_data;
} else if (is_better_name(name, tip_name, taggerdate,
generation, distance, from_tag)) {
if (o->type != OBJ_COMMIT)
return get_exact_ref_match(o);
c = (struct commit *) o;
- n = c->util;
+ n = get_commit_rev_name(c);
if (!n)
return NULL;
else if (allow_undefined)
printf("undefined\n");
else if (always)
- printf("%s\n", find_unique_abbrev(oid->hash, DEFAULT_ABBREV));
+ printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
else
die("cannot describe '%s'", oid_to_hex(oid));
strbuf_release(&buf);
OPT_END(),
};
+ init_commit_rev_name(&rev_names);
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
if (all + transform_stdin + !!argc > 1) {