From: Teng Long <dyroneteng@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, avarab@gmail.com, jonathantanmy@google.com,
bagasdotme@gmail.com, adlternative@gmail.com, stolee@gmail.com,
Teng Long <dyroneteng@gmail.com>
Subject: [PATCH v6 10/12] packfile-uri: support for excluding tags
Date: Tue, 19 Oct 2021 19:38:34 +0800 [thread overview]
Message-ID: <16c41c40a26e72d64959a332fbf7dc1c9794e70c.1634634814.git.tenglong@alibaba-inc.com> (raw)
In-Reply-To: <cover.1634634814.git.tenglong@alibaba-inc.com>
From: Teng Long <dyroneteng@gmail.com>
This commit brings the tags exclusion feature of packfile-uri. The
excluding level of tag is supported with "ET_SELF", "ET_INCLUDE"
and "ET_REACHABLE".
Exclusion scope on different level:
1. When a tag is specified to be excluded with level "ET_SELF",
only the tag object itself will be excluded.
2. When it's specified to be excluded with level "ET_INCLUDE",
exclude the referenced commit, and all trees and blobs contained in its
top-level. If it's a annotated tag, the tag object will be excluded
too.
3. When it is specified with level "ET_REACHABLE", exclude the ancestors
of the referenced commit, as well as the objects need to be excluded
under the level "ET_INCLUDED".
Signed-off-by: Teng Long <dyroneteng@gmail.com>
---
builtin/pack-objects.c | 6 +++++-
list-objects.c | 20 ++++++++++++++++----
object.c | 1 +
object.h | 1 +
revision.c | 13 ++++++++++++-
revision.h | 9 +++++++++
6 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 6713e734fb..073c3815a1 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1416,6 +1416,9 @@ static int want_object_in_pack(const struct object_id *oid,
if (referred_objs) {
struct commit *commit = referred_objs->commit;
struct object_list *trees = referred_objs->trees;
+ struct object_list *tags = referred_objs->tags;
+ if (want_exclude_object(tags))
+ return 0;
if (commit) {
commit_ex = oidmap_get(&configured_exclusions, &commit->object.oid);
if (match_packfile_uri_exclusions(commit_ex) && commit_ex->level > ET_SELF)
@@ -3344,7 +3347,8 @@ static void read_object_list_from_stdin(void)
static void show_commit(struct commit *commit, struct show_info *info)
{
- add_object_entry(&commit->object.oid, OBJ_COMMIT, NULL, 0, NULL);
+ struct referred_objects *referred_objs = info->show_cache;
+ add_object_entry(&commit->object.oid, OBJ_COMMIT, NULL, 0, referred_objs);
commit->object.flags |= OBJECT_ADDED;
if (write_bitmap_index)
diff --git a/list-objects.c b/list-objects.c
index 40292e2cc8..2e241e8707 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -348,9 +348,10 @@ static void traverse_trees_and_blobs(struct traversal_context *ctx,
for (i = 0; i < ctx->revs->pending.nr; i++) {
struct object_array_entry *pending = ctx->revs->pending.objects + i;
struct object *obj = pending->item;
- struct referred_objects *referred_objs = pending->referred_objects;
const char *name = pending->name;
const char *path = pending->path;
+ struct referred_objects *referred_objs = pending->referred_objects;
+ struct commit_wraps_entry *cw_entry = NULL;
if (obj->flags & (UNINTERESTING | SEEN))
continue;
if (obj->type == OBJ_TAG) {
@@ -358,6 +359,10 @@ static void traverse_trees_and_blobs(struct traversal_context *ctx,
ctx->show_object(obj, name, &show_info);
continue;
}
+ if (referred_objs->commit)
+ cw_entry = oidmap_get(ctx->revs->commit_wraps, &referred_objs->commit->object.oid);
+ if (cw_entry)
+ referred_objs->tags = cw_entry->wraps;
if (!path)
path = "";
if (obj->type == OBJ_TREE) {
@@ -378,12 +383,14 @@ static void do_traverse(struct traversal_context *ctx)
{
struct commit *commit;
struct strbuf csp; /* callee's scratch pad */
- struct show_info show_info;
+ struct commit_wraps_entry *entry;
+ struct oidmap *commit_wraps = ctx->revs->commit_wraps;
+ struct referred_objects referred_objs = { NULL, NULL, NULL };
+ struct show_info show_info = { ctx->show_data , NULL };
strbuf_init(&csp, PATH_MAX);
-
show_info.show_data = ctx->show_data;
- show_info.show_cache = NULL;
+ show_info.show_cache = &referred_objs;
while ((commit = get_revision(ctx->revs)) != NULL) {
/*
@@ -401,6 +408,11 @@ static void do_traverse(struct traversal_context *ctx)
oid_to_hex(&commit->object.oid));
}
+ if (commit_wraps) {
+ entry = oidmap_get(commit_wraps, &commit->object.oid);
+ referred_objs.tags = entry ? entry->wraps : NULL;
+ }
+
ctx->show_commit(commit, &show_info);
if (ctx->revs->tree_blobs_in_commit_order)
diff --git a/object.c b/object.c
index 895068cbc2..167cc87ec9 100644
--- a/object.c
+++ b/object.c
@@ -335,6 +335,7 @@ void add_object_array_with_path_and_referred_commit(struct object *obj, const ch
referred_objs = xmalloc(sizeof(struct referred_objects));
referred_objs->commit = referred_commit;
referred_objs->trees = NULL;
+ referred_objs->tags = NULL;
if (nr >= alloc) {
alloc = (alloc + 32) * 2;
diff --git a/object.h b/object.h
index 618d674249..42a2178531 100644
--- a/object.h
+++ b/object.h
@@ -66,6 +66,7 @@ struct object_array {
struct referred_objects{
struct commit *commit;
struct object_list *trees;
+ struct object_list *tags;
};
#define OBJECT_ARRAY_INIT { 0, 0, NULL }
diff --git a/revision.c b/revision.c
index 89a8b311ea..d16f9bbbb9 100644
--- a/revision.c
+++ b/revision.c
@@ -416,14 +416,17 @@ static struct commit *handle_commit(struct rev_info *revs,
const char *path = entry->path;
unsigned int mode = entry->mode;
unsigned long flags = object->flags;
+ struct object_list *wraps = NULL;
/*
* Tag object? Look what it points to..
*/
while (object->type == OBJ_TAG) {
struct tag *tag = (struct tag *) object;
- if (revs->tag_objects && !(flags & UNINTERESTING))
+ if (revs->tag_objects && !(flags & UNINTERESTING)) {
add_pending_object(revs, object, tag->tag);
+ object_list_insert(object, &wraps);
+ }
object = parse_object(revs->repo, get_tagged_oid(tag));
if (!object) {
if (revs->ignore_missing_links || (flags & UNINTERESTING))
@@ -449,6 +452,14 @@ static struct commit *handle_commit(struct rev_info *revs,
*/
if (object->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)object;
+ struct oidmap *commit_wraps = malloc(sizeof(struct oidmap));
+ struct commit_wraps_entry *cw_entry = xmalloc(sizeof(struct commit_wraps_entry));
+
+ oidmap_init(commit_wraps, 0);
+ cw_entry->e.oid = object->oid;
+ cw_entry->wraps = wraps;
+ oidmap_put(commit_wraps, cw_entry);
+ revs->commit_wraps = commit_wraps;
if (repo_parse_commit(revs->repo, commit) < 0)
die("unable to parse commit %s", name);
diff --git a/revision.h b/revision.h
index b2e0c0b9b7..a633ea2174 100644
--- a/revision.h
+++ b/revision.h
@@ -8,6 +8,7 @@
#include "pretty.h"
#include "diff.h"
#include "commit-slab-decl.h"
+#include "oidmap.h"
/**
* The revision walking API offers functions to build a list of revisions
@@ -64,6 +65,11 @@ struct bloom_key;
struct bloom_filter_settings;
define_shared_commit_slab(revision_sources, char *);
+struct commit_wraps_entry {
+ struct oidmap_entry e;
+ struct object_list *wraps;
+};
+
struct rev_cmdline_info {
unsigned int nr;
unsigned int alloc;
@@ -321,6 +327,9 @@ struct rev_info {
/* misc. flags related to '--no-kept-objects' */
unsigned keep_pack_cache_flags;
+
+ /* The commit_wraps caches the referred wrapped objects(such as tags) of a commit */
+ struct oidmap *commit_wraps;
};
int ref_excluded(struct string_list *, const char *path);
--
2.31.1.453.g945ddc3a74.dirty
next prev parent reply other threads:[~2021-10-19 11:40 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 2:11 [PATCH] Packfile-uris support excluding commit objects Teng Long
2021-05-10 11:14 ` Ævar Arnfjörð Bjarmason
2021-05-18 8:49 ` [PATCH v2 0/3] packfile-uris: commit objects exclusion Teng Long
2021-05-18 8:49 ` [PATCH v2 1/3] packfile-uris: support for excluding commit object Teng Long
2021-05-19 4:28 ` Junio C Hamano
2021-05-20 4:46 ` Junio C Hamano
2021-05-18 8:49 ` [PATCH v2 2/3] packfile-uris.txt: " Teng Long
2021-05-18 8:49 ` [PATCH v2 3/3] t5702: excluding commits with packfile-uris Teng Long
2021-07-26 9:46 ` [PATCH v3 0/3] packfile-uris: commit objects exclusio Teng Long
2021-07-26 9:46 ` [PATCH v3 1/3] packfile-uris: support for excluding commit objects Teng Long
2021-07-26 18:15 ` Junio C Hamano
2021-07-26 19:45 ` Felipe Contreras
2021-08-11 1:44 ` Teng Long
2021-07-26 9:46 ` [PATCH v3 2/3] t5702: " Teng Long
2021-07-26 15:03 ` Ævar Arnfjörð Bjarmason
2021-08-11 1:46 ` [PATCH v3 1/3] packfile-uris: " Teng Long
2021-07-26 9:46 ` [PATCH v3 3/3] packfile-uri.txt: " Teng Long
2021-07-26 20:52 ` Junio C Hamano
2021-08-11 1:47 ` Teng Long
2021-07-26 12:34 ` [PATCH v3 0/3] packfile-uris: commit objects exclusio Ævar Arnfjörð Bjarmason
2021-08-11 1:48 ` Teng Long
2021-08-11 7:45 ` [PATCH v4 0/7] packfile-uris: commits and trees exclusion Teng Long
2021-08-11 7:45 ` [PATCH v4 1/7] pack-objects.c: introduce new method `match_packfile_uri_exclusions` Teng Long
2021-08-11 7:45 ` [PATCH v4 2/7] Add new parameter "carry_data" for "show_object" function Teng Long
2021-08-11 7:45 ` [PATCH v4 3/7] packfile-uri: support for excluding commit objects Teng Long
2021-08-11 7:45 ` [PATCH v4 4/7] packfile-uri: support for excluding tree objects Teng Long
2021-08-11 7:45 ` [PATCH v4 5/7] packfile-uri.txt: support for excluding commits and trees Teng Long
2021-08-11 9:59 ` Bagas Sanjaya
2021-08-11 7:45 ` [PATCH v4 6/7] t5702: replace with "test_when_finished" for cleanup Teng Long
2021-08-11 7:45 ` [PATCH v4 7/7] t5702: support for excluding commit objects Teng Long
2021-08-25 2:21 ` [PATCH v5 00/14] packfile-uris: commits, trees and tags exclusion Teng Long
2021-08-25 2:21 ` [PATCH v5 01/14] pack-objects.c: introduce new method `match_packfile_uri_exclusions` Teng Long
2021-08-25 2:21 ` [PATCH v5 02/14] Add new parameter "carry_data" for "show_object" function Teng Long
2021-08-26 20:45 ` Junio C Hamano
2021-09-02 11:08 ` Teng Long
2021-08-25 2:21 ` [PATCH v5 03/14] packfile-uri: support for excluding commit objects Teng Long
2021-08-25 23:49 ` Ævar Arnfjörð Bjarmason
2021-09-02 12:26 ` Teng Long
2021-08-26 20:56 ` Junio C Hamano
2021-09-02 12:51 ` Teng Long
2021-08-25 2:21 ` [PATCH v5 04/14] packfile-uri: support for excluding tree objects Teng Long
2021-08-25 2:21 ` [PATCH v5 05/14] packfile-uri.txt: support for excluding commits and trees Teng Long
2021-08-25 23:52 ` Ævar Arnfjörð Bjarmason
2021-09-02 11:23 ` Teng Long
2021-08-25 2:21 ` [PATCH v5 06/14] t5702: replace with "test_when_finished" for cleanup Teng Long
2021-08-25 23:55 ` Ævar Arnfjörð Bjarmason
2021-09-02 11:37 ` Teng Long
2021-08-25 2:21 ` [PATCH v5 07/14] t5702: support for excluding commit objects Teng Long
2021-08-25 2:21 ` [PATCH v5 08/14] Add new parameter "carry_data" for "show_commit function Teng Long
2021-08-25 2:21 ` [PATCH v5 09/14] commit.h: add wrapped tags in commit struct Teng Long
2021-08-25 23:58 ` Ævar Arnfjörð Bjarmason
2021-09-02 12:17 ` Teng Long
2021-09-02 12:39 ` ZheNing Hu
2021-09-02 13:01 ` Teng Long
2021-08-25 2:21 ` [PATCH v5 10/14] object.h: add referred tags in `referred_objects` struct Teng Long
2021-08-25 2:21 ` [PATCH v5 11/14] packfile-uri: support for excluding tag objects Teng Long
2021-08-25 2:21 ` [PATCH v5 12/14] packfile-uri.txt: " Teng Long
2021-08-25 2:21 ` [PATCH v5 13/14] t5702: add tag exclusion test case Teng Long
2021-08-25 2:21 ` [PATCH v5 14/14] pack-objects.c: introduce `want_exclude_object` function Teng Long
2021-10-19 11:38 ` [PATCH v6 00/12] packfile-uri: support excluding multiple object types Teng Long
2021-10-19 11:38 ` [PATCH v6 01/12] objects.c: introduce `exclude_level` enum Teng Long
2021-10-19 11:38 ` [PATCH v6 02/12] Introduce function `match_packfile_uri_exclusions` Teng Long
2021-10-19 11:38 ` [PATCH v6 03/12] Replace `show_data` with structure `show_info` Teng Long
2021-10-19 11:38 ` [PATCH v6 04/12] Introduce `uploadpack.excludeobject` configuration Teng Long
2021-10-19 11:38 ` [PATCH v6 05/12] t5702: test cases for `uploadpack.excludeobject` Teng Long
2021-10-19 11:38 ` [PATCH v6 06/12] packfile-uri: support for excluding commits Teng Long
2021-10-19 11:38 ` [PATCH v6 07/12] t5702: test cases " Teng Long
2021-10-19 11:38 ` [PATCH v6 08/12] packfile-uri: support for excluding trees Teng Long
2021-10-19 11:38 ` [PATCH v6 09/12] t5702: test cases " Teng Long
2021-10-19 11:38 ` Teng Long [this message]
2021-10-19 11:38 ` [PATCH v6 11/12] t5702: test cases for excluding tags Teng Long
2021-10-19 11:38 ` [PATCH v6 12/12] packfile-uri.txt: support multiple object types Teng Long
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=16c41c40a26e72d64959a332fbf7dc1c9794e70c.1634634814.git.tenglong@alibaba-inc.com \
--to=dyroneteng@gmail.com \
--cc=adlternative@gmail.com \
--cc=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=stolee@gmail.com \
/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).