From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 08/12] name-rev: use commit-slab for rev-name instead of commit->util
Date: Sat, 12 May 2018 10:00:24 +0200 [thread overview]
Message-ID: <20180512080028.29611-9-pclouds@gmail.com> (raw)
In-Reply-To: <20180512080028.29611-1-pclouds@gmail.com>
It's done so that commit->util can be removed. See more explanation in
the commit that removes commit->util.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/name-rev.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 387ddf85d2..0eb440359d 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -6,6 +6,7 @@
#include "refs.h"
#include "parse-options.h"
#include "sha1-lookup.h"
+#include "commit-slab.h"
#define CUTOFF_DATE_SLOP 86400 /* one day */
@@ -17,11 +18,26 @@ typedef struct rev_name {
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,
@@ -65,7 +81,7 @@ static void name_rev(struct commit *commit,
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;
@@ -84,7 +100,7 @@ static void name_rev(struct commit *commit,
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)) {
@@ -296,7 +312,7 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf)
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;
@@ -413,6 +429,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
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) {
--
2.17.0.705.g3525833791
next prev parent reply other threads:[~2018-05-12 8:01 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-12 8:00 [PATCH 00/12] Die commit->util, die! Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 01/12] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-12 9:22 ` Jeff King
2018-05-12 12:13 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 02/12] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 03/12] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-12 9:07 ` Jeff King
2018-05-12 9:18 ` Jeff King
2018-05-12 12:09 ` Duy Nguyen
2018-05-12 19:12 ` Jeff King
2018-05-12 11:59 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 04/12] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-12 9:25 ` Jeff King
2018-05-12 13:43 ` Junio C Hamano
2018-05-12 14:00 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 05/12] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-12 9:28 ` Jeff King
2018-05-12 8:00 ` [PATCH 06/12] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-12 9:33 ` Jeff King
2018-05-12 13:58 ` Junio C Hamano
2018-05-12 14:13 ` Duy Nguyen
2018-05-12 19:06 ` Jeff King
2018-05-12 8:00 ` [PATCH 07/12] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-12 13:59 ` Junio C Hamano
2018-05-12 8:00 ` Nguyễn Thái Ngọc Duy [this message]
2018-05-12 8:00 ` [PATCH 09/12] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 10/12] log: use commit-slab in prepare_bases() " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 11/12] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 12/12] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-12 9:41 ` [PATCH 00/12] Die commit->util, die! Jeff King
2018-05-12 18:50 ` Jakub Narebski
2018-05-13 5:39 ` Duy Nguyen
2018-05-13 5:51 ` [PATCH v2 00/14] " Nguyễn Thái Ngọc Duy
2018-05-13 5:51 ` [PATCH v2 01/14] commit-slab.h: code split Nguyễn Thái Ngọc Duy
2018-05-13 23:33 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 02/14] commit-slab: support shared commit-slab Nguyễn Thái Ngọc Duy
2018-05-13 23:36 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 03/14] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-13 23:42 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 04/14] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-13 23:45 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 05/14] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 06/14] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-14 4:17 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 07/14] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 08/14] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-14 5:10 ` Junio C Hamano
2018-05-14 5:37 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 09/14] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-14 6:16 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 10/14] name-rev: use commit-slab for rev-name " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 11/14] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-14 6:45 ` Junio C Hamano
2018-05-19 4:51 ` Duy Nguyen
2018-05-13 5:52 ` [PATCH v2 12/14] log: use commit-slab in prepare_bases() " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 13/14] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-18 2:16 ` Junio C Hamano
2018-05-18 17:54 ` Ramsay Jones
2018-05-13 5:52 ` [PATCH v2 14/14] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-14 7:52 ` Junio C Hamano
2018-05-14 16:07 ` Duy Nguyen
2018-05-14 17:30 ` Duy Nguyen
2018-05-14 18:14 ` Derrick Stolee
2018-05-19 5:41 ` Duy Nguyen
2018-05-19 5:28 ` [PATCH v3 00/15] Die commit->util, die! Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 01/15] commit-slab.h: code split Nguyễn Thái Ngọc Duy
2018-05-21 5:11 ` Junio C Hamano
2018-05-19 5:28 ` [PATCH v3 02/15] commit-slab: support shared commit-slab Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 03/15] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 04/15] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 05/15] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 06/15] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 07/15] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 08/15] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 09/15] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 10/15] name-rev: use commit-slab for rev-name " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 11/15] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 12/15] show-branch: note about its object flags usage Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 13/15] log: use commit-slab in prepare_bases() instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 14/15] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 15/15] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-22 22:40 ` [PATCH 00/12] Die commit->util, die! Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180512080028.29611-9-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).