summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-06-25 13:22:35 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-06-25 13:22:35 -0700
commitb3b2aaf0fd6c65f83d5f636bb177d96c88079b13 (patch)
treeeaa7c8b7182b645e65f26278113f5d3a9e7b13a8 /commit.c
parentMerge branch 'pc/submodule-helper-foreach' (diff)
parentcommit.h: delete 'util' field in struct commit (diff)
downloadtgif-b3b2aaf0fd6c65f83d5f636bb177d96c88079b13.tar.xz
Merge branch 'nd/commit-util-to-slab'
The in-core "commit" object had an all-purpose "void *util" field, which was tricky to use especially in library-ish part of the code. All of the existing uses of the field has been migrated to a more dedicated "commit-slab" mechanism and the field is eliminated. * nd/commit-util-to-slab: commit.h: delete 'util' field in struct commit merge: use commit-slab in merge remote desc instead of commit->util log: use commit-slab in prepare_bases() instead of commit->util show-branch: note about its object flags usage show-branch: use commit-slab for commit-name instead of commit->util name-rev: use commit-slab for rev-name instead of commit->util bisect.c: use commit-slab for commit weight instead of commit->util revision.c: use commit-slab for show_source sequencer.c: use commit-slab to associate todo items to commits sequencer.c: use commit-slab to mark seen commits shallow.c: use commit-slab for commit depth instead of commit->util describe: use commit-slab for commit names instead of commit->util blame: use commit-slab for blame suspects instead of commit->util commit-slab: support shared commit-slab commit-slab.h: code split
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index 0030e79940..2d4431a21f 100644
--- a/commit.c
+++ b/commit.c
@@ -1605,13 +1605,21 @@ out:
return result;
}
+define_commit_slab(merge_desc_slab, struct merge_remote_desc *);
+static struct merge_desc_slab merge_desc_slab = COMMIT_SLAB_INIT(1, merge_desc_slab);
+
+struct merge_remote_desc *merge_remote_util(struct commit *commit)
+{
+ return *merge_desc_slab_at(&merge_desc_slab, commit);
+}
+
void set_merge_remote_desc(struct commit *commit,
const char *name, struct object *obj)
{
struct merge_remote_desc *desc;
FLEX_ALLOC_STR(desc, name, name);
desc->obj = obj;
- commit->util = desc;
+ *merge_desc_slab_at(&merge_desc_slab, commit) = desc;
}
struct commit *get_merge_parent(const char *name)
@@ -1623,7 +1631,7 @@ struct commit *get_merge_parent(const char *name)
return NULL;
obj = parse_object(&oid);
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
- if (commit && !commit->util)
+ if (commit && !merge_remote_util(commit))
set_merge_remote_desc(commit, name, obj);
return commit;
}