Skip to content

Commit b2025da

Browse files
pks-tgitster
authored andcommitted
revision: mark commit parents as NOT_USER_GIVEN
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a812789 commit b2025da

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
11231123
mark_parents_uninteresting(p);
11241124
if (p->object.flags & SEEN)
11251125
continue;
1126-
p->object.flags |= SEEN;
1126+
p->object.flags |= (SEEN | NOT_USER_GIVEN);
11271127
if (list)
11281128
commit_list_insert_by_date(p, list);
11291129
if (queue)
@@ -1165,7 +1165,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
11651165
}
11661166
p->object.flags |= left_flag;
11671167
if (!(p->object.flags & SEEN)) {
1168-
p->object.flags |= SEEN;
1168+
p->object.flags |= (SEEN | NOT_USER_GIVEN);
11691169
if (list)
11701170
commit_list_insert_by_date(p, list);
11711171
if (queue)

revision.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
/*
4545
* Indicates object was reached by traversal. i.e. not given by user on
4646
* command-line or stdin.
47-
* NEEDSWORK: NOT_USER_GIVEN doesn't apply to commits because we only support
48-
* filtering trees and blobs, but it may be useful to support filtering commits
49-
* in the future.
5047
*/
5148
#define NOT_USER_GIVEN (1u<<25)
5249
#define TRACK_LINEAR (1u<<26)

0 commit comments

Comments
 (0)