]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: mark commit parents as NOT_USER_GIVEN
authorPatrick Steinhardt <ps@pks.im>
Fri, 9 Apr 2021 11:27:57 +0000 (13:27 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 11 Apr 2021 06:03:20 +0000 (23:03 -0700)
The NOT_USER_GIVEN flag of an object marks whether a flag was explicitly
provided by the user or not. The most important use case for this is
when filtering objects: only objects that were not explicitly requested
will get filtered.

The flag is currently only set for blobs and trees, which has been fine
given that there are no filters for tags or commits currently. We're
about to extend filtering capabilities to add object type filter though,
which requires us to set up the NOT_USER_GIVEN flag correctly -- if it's
not set, the object wouldn't get filtered at all.

Mark unseen commit parents as NOT_USER_GIVEN when processing parents.
Like this, explicitly provided parents stay user-given and thus
unfiltered, while parents which get loaded as part of the graph walk
can be filtered.

This commit shouldn't have any user-visible impact yet as there is no
logic to filter commits yet.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c
revision.h

index 553c0faa9b3805c66c1d179b6a8c68ab20dcb2da..fd34c75e238877686f3c8c2eebdcf70afb05fbb8 100644 (file)
@@ -1123,7 +1123,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
                                mark_parents_uninteresting(p);
                        if (p->object.flags & SEEN)
                                continue;
-                       p->object.flags |= SEEN;
+                       p->object.flags |= (SEEN | NOT_USER_GIVEN);
                        if (list)
                                commit_list_insert_by_date(p, list);
                        if (queue)
@@ -1165,7 +1165,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
                }
                p->object.flags |= left_flag;
                if (!(p->object.flags & SEEN)) {
-                       p->object.flags |= SEEN;
+                       p->object.flags |= (SEEN | NOT_USER_GIVEN);
                        if (list)
                                commit_list_insert_by_date(p, list);
                        if (queue)
index a24f72dcd151a3146d971832db9ee703809845b9..93aa012f518eb0661661f10408020e93cd8ec604 100644 (file)
@@ -44,9 +44,6 @@
 /*
  * Indicates object was reached by traversal. i.e. not given by user on
  * command-line or stdin.
- * NEEDSWORK: NOT_USER_GIVEN doesn't apply to commits because we only support
- * filtering trees and blobs, but it may be useful to support filtering commits
- * in the future.
  */
 #define NOT_USER_GIVEN (1u<<25)
 #define TRACK_LINEAR   (1u<<26)