aboutsummaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-25 11:54:17 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-25 11:54:17 -0800
commit8d15dd1ce10f8d066ed058917f3183ec3efd7f95 (patch)
treecef824aa822c183db52f94873c382a169eb97975 /revision.c
parent6b5ad01886b9492d8662509604277fc88e705dcb (diff)
parentb4e8f60a3c78477e1f28b052cd740ac4a43741d5 (diff)
downloadgit-8d15dd1ce10f8d066ed058917f3183ec3efd7f95.tar.xz
Merge branch 'ds/revision-maximal-only'
"git rev-list" and friends learn "--maximal-only" to show only the commits that are not reachable by other commits. * ds/revision-maximal-only: revision: add --maximal-only option
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/revision.c b/revision.c
index 29972c3a19..047ff7e458 100644
--- a/revision.c
+++ b/revision.c
@@ -1150,7 +1150,8 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
struct commit *p = parent->item;
parent = parent->next;
if (p)
- p->object.flags |= UNINTERESTING;
+ p->object.flags |= UNINTERESTING |
+ CHILD_VISITED;
if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
continue;
if (p->parents)
@@ -1204,7 +1205,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
if (!*slot)
*slot = *revision_sources_at(revs->sources, commit);
}
- p->object.flags |= pass_flags;
+ p->object.flags |= pass_flags | CHILD_VISITED;
if (!(p->object.flags & SEEN)) {
p->object.flags |= (SEEN | NOT_USER_GIVEN);
if (list)
@@ -2377,6 +2378,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if ((argcount = parse_long_opt("until", argv, &optarg))) {
revs->min_age = approxidate(optarg);
return argcount;
+ } else if (!strcmp(arg, "--maximal-only")) {
+ revs->maximal_only = 1;
} else if (!strcmp(arg, "--first-parent")) {
revs->first_parent_only = 1;
} else if (!strcmp(arg, "--exclude-first-parent-only")) {
@@ -3147,6 +3150,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
!!revs->reverse, "--reverse",
!!revs->reflog_info, "--walk-reflogs");
+ die_for_incompatible_opt2(!!revs->boundary, "--boundary",
+ !!revs->maximal_only, "--maximal-only");
+
if (revs->no_walk && revs->graph)
die(_("options '%s' and '%s' cannot be used together"), "--no-walk", "--graph");
if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
@@ -4125,6 +4131,8 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
{
if (commit->object.flags & SHOWN)
return commit_ignore;
+ if (revs->maximal_only && (commit->object.flags & CHILD_VISITED))
+ return commit_ignore;
if (revs->unpacked && has_object_pack(revs->repo, &commit->object.oid))
return commit_ignore;
if (revs->no_kept_objects) {