list-objects: support filtering by tag and commit
Object filters currently only support filtering blobs or trees based on some criteria. This commit lays the foundation to also allow filtering of tags and commits. No change in behaviour is expected from this commit given that there are no filters yet for those object types. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
628d81be6c
commit
9a2a4f9544
@ -82,6 +82,16 @@ static enum list_objects_filter_result filter_blobs_none(
|
|||||||
default:
|
default:
|
||||||
BUG("unknown filter_situation: %d", filter_situation);
|
BUG("unknown filter_situation: %d", filter_situation);
|
||||||
|
|
||||||
|
case LOFS_TAG:
|
||||||
|
assert(obj->type == OBJ_TAG);
|
||||||
|
/* always include all tag objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
|
case LOFS_COMMIT:
|
||||||
|
assert(obj->type == OBJ_COMMIT);
|
||||||
|
/* always include all commit objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
case LOFS_BEGIN_TREE:
|
case LOFS_BEGIN_TREE:
|
||||||
assert(obj->type == OBJ_TREE);
|
assert(obj->type == OBJ_TREE);
|
||||||
/* always include all tree objects */
|
/* always include all tree objects */
|
||||||
@ -173,6 +183,16 @@ static enum list_objects_filter_result filter_trees_depth(
|
|||||||
default:
|
default:
|
||||||
BUG("unknown filter_situation: %d", filter_situation);
|
BUG("unknown filter_situation: %d", filter_situation);
|
||||||
|
|
||||||
|
case LOFS_TAG:
|
||||||
|
assert(obj->type == OBJ_TAG);
|
||||||
|
/* always include all tag objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
|
case LOFS_COMMIT:
|
||||||
|
assert(obj->type == OBJ_COMMIT);
|
||||||
|
/* always include all commit objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
case LOFS_END_TREE:
|
case LOFS_END_TREE:
|
||||||
assert(obj->type == OBJ_TREE);
|
assert(obj->type == OBJ_TREE);
|
||||||
filter_data->current_depth--;
|
filter_data->current_depth--;
|
||||||
@ -267,6 +287,16 @@ static enum list_objects_filter_result filter_blobs_limit(
|
|||||||
default:
|
default:
|
||||||
BUG("unknown filter_situation: %d", filter_situation);
|
BUG("unknown filter_situation: %d", filter_situation);
|
||||||
|
|
||||||
|
case LOFS_TAG:
|
||||||
|
assert(obj->type == OBJ_TAG);
|
||||||
|
/* always include all tag objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
|
case LOFS_COMMIT:
|
||||||
|
assert(obj->type == OBJ_COMMIT);
|
||||||
|
/* always include all commit objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
case LOFS_BEGIN_TREE:
|
case LOFS_BEGIN_TREE:
|
||||||
assert(obj->type == OBJ_TREE);
|
assert(obj->type == OBJ_TREE);
|
||||||
/* always include all tree objects */
|
/* always include all tree objects */
|
||||||
@ -371,6 +401,16 @@ static enum list_objects_filter_result filter_sparse(
|
|||||||
default:
|
default:
|
||||||
BUG("unknown filter_situation: %d", filter_situation);
|
BUG("unknown filter_situation: %d", filter_situation);
|
||||||
|
|
||||||
|
case LOFS_TAG:
|
||||||
|
assert(obj->type == OBJ_TAG);
|
||||||
|
/* always include all tag objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
|
case LOFS_COMMIT:
|
||||||
|
assert(obj->type == OBJ_COMMIT);
|
||||||
|
/* always include all commit objects */
|
||||||
|
return LOFR_MARK_SEEN | LOFR_DO_SHOW;
|
||||||
|
|
||||||
case LOFS_BEGIN_TREE:
|
case LOFS_BEGIN_TREE:
|
||||||
assert(obj->type == OBJ_TREE);
|
assert(obj->type == OBJ_TREE);
|
||||||
dtype = DT_DIR;
|
dtype = DT_DIR;
|
||||||
|
@ -55,6 +55,8 @@ enum list_objects_filter_result {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum list_objects_filter_situation {
|
enum list_objects_filter_situation {
|
||||||
|
LOFS_COMMIT,
|
||||||
|
LOFS_TAG,
|
||||||
LOFS_BEGIN_TREE,
|
LOFS_BEGIN_TREE,
|
||||||
LOFS_END_TREE,
|
LOFS_END_TREE,
|
||||||
LOFS_BLOB
|
LOFS_BLOB
|
||||||
|
@ -217,8 +217,15 @@ static void process_tag(struct traversal_context *ctx,
|
|||||||
struct tag *tag,
|
struct tag *tag,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
tag->object.flags |= SEEN;
|
enum list_objects_filter_result r;
|
||||||
ctx->show_object(&tag->object, name, ctx->show_data);
|
|
||||||
|
r = list_objects_filter__filter_object(ctx->revs->repo, LOFS_TAG,
|
||||||
|
&tag->object, NULL, NULL,
|
||||||
|
ctx->filter);
|
||||||
|
if (r & LOFR_MARK_SEEN)
|
||||||
|
tag->object.flags |= SEEN;
|
||||||
|
if (r & LOFR_DO_SHOW)
|
||||||
|
ctx->show_object(&tag->object, name, ctx->show_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_edge_parents_uninteresting(struct commit *commit,
|
static void mark_edge_parents_uninteresting(struct commit *commit,
|
||||||
@ -368,6 +375,12 @@ static void do_traverse(struct traversal_context *ctx)
|
|||||||
strbuf_init(&csp, PATH_MAX);
|
strbuf_init(&csp, PATH_MAX);
|
||||||
|
|
||||||
while ((commit = get_revision(ctx->revs)) != NULL) {
|
while ((commit = get_revision(ctx->revs)) != NULL) {
|
||||||
|
enum list_objects_filter_result r;
|
||||||
|
|
||||||
|
r = list_objects_filter__filter_object(ctx->revs->repo,
|
||||||
|
LOFS_COMMIT, &commit->object,
|
||||||
|
NULL, NULL, ctx->filter);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* an uninteresting boundary commit may not have its tree
|
* an uninteresting boundary commit may not have its tree
|
||||||
* parsed yet, but we are not going to show them anyway
|
* parsed yet, but we are not going to show them anyway
|
||||||
@ -382,7 +395,11 @@ static void do_traverse(struct traversal_context *ctx)
|
|||||||
die(_("unable to load root tree for commit %s"),
|
die(_("unable to load root tree for commit %s"),
|
||||||
oid_to_hex(&commit->object.oid));
|
oid_to_hex(&commit->object.oid));
|
||||||
}
|
}
|
||||||
ctx->show_commit(commit, ctx->show_data);
|
|
||||||
|
if (r & LOFR_MARK_SEEN)
|
||||||
|
commit->object.flags |= SEEN;
|
||||||
|
if (r & LOFR_DO_SHOW)
|
||||||
|
ctx->show_commit(commit, ctx->show_data);
|
||||||
|
|
||||||
if (ctx->revs->tree_blobs_in_commit_order)
|
if (ctx->revs->tree_blobs_in_commit_order)
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user